Ozapell Basic Learn Programming #6

A subroutine is a section of code that can be executed once or many times. The code in a subroutine is encapsulated. If properly designed, a subroutine could be used by other programs after its first development. Make code reusable to save time.

In Ozapell Basic, a new subroutine is declared using the SUB statement.

The main section of an Ozapell Basic program is always at the top of the source code. All subroutines declared must be after the main section. The compiler determines that the main section has ended when it encounters the first SUB declaration or the end of the source code.


FOR X=1 to 10





In this example, the subroutine PRINTIT is declared. The compiler determines the end of the subroutine when it either encounters the next SUB declaration or reaches the end of the source code.

PRINTIT is called by writing its name alone as a line of code. Each time PRINTIT is called, the code will execute. In this example, the text string “HELLO” will be assigned to the variable TEXT and the built-in display routine PRINTLINE will show HELLO on the screen.

PRINTLINE is a built-in subroutine that uses the variable TEXT. New subroutines can use any variable available as long as the variable is declared before calling the subroutine.

INPUT is a built-in subroutine returning a key pressed in the RESULT variable. New subroutines can declare and return any variables necessary.

Ozapell Basic on Steam


Ozapell Basic Learn Programming #6

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s