GOSUB

This command will jump to the specified label in the program.

  Syntax
GOSUB SubroutineLabel
  Parameters
SubroutineLabel
Value
Enter the appropriate value here.

  Returns

This command does not return a value.

  Description

Unlike the GOTO command, you can use the RETURN command to return to the program location of the last jump performed. In order to use the GOSUB command you must create a subroutine in your program that terminates with the RETURN command. To create a subroutine you must write a label in your program followed by a sequence of commands. The label can be made up from any combination of alphabetic characters, but you must end the declaration of the label using a colon(:). You only need to use a colon when you are declaring the label, and should not be used when calling the label from a GOSUB command.

  Example Code
PRINT "start"
GOSUB _subroutine
WAIT KEY
END
_subroutine:
PRINT "inside subroutine"
RETURN
  See also

CORE Commands Menu
Index