Subroutines and functions
A subroutine (also called a "module") is a "mini-program" inside your program. In other words, it
is a collection of commands--and can be executed anywhere in your program.
To create a subroutine:
- Go to the "Edit" menu
- Select "New Sub"
- Enter a name for the subroutine
- Type a list of commands between SUB and END SUB
To use the subroutine:
- Press F2
- Select "Untitled"
- Press Enter to return to the "main module"
- Use CALL to execute the subroutine
TIP: Another way to create a subroutine is by
typing SUB <name> in the main module.
SUB MySub
The following example does not use subroutines:
PRINT "Enter some text:";
INPUT text$PRINT "The text you entered was: "; text$
PRINT "Enter some text:";INPUT text$
PRINT "The text you entered was: "; text$
PRINT "Enter some text:";INPUT text$
PRINT "The text you entered was: "; text$
PRINT "Enter some text:";
INPUT text$PRINT "The text you entered was: "; text$
PRINT "Enter some text:";INPUT text$
PRINT "The text you entered was: "; text$