Gosub
Positron16 · Revision 1.1.3.5 · PDF page 337
Syntax
Gosub Label
Overview
Gosub jumps the program to a defined label and continues execution from there. Once the program hits a Return command the program returns to the instruction following the Gosub that called it and continues execution from that point.
Parameters
Label is a user-defined label.
Example 1
' Implement a standard subroutine call
GoTo Main ' Jump over the subroutines
SubA:
subroutine A code
……
……
Return
SubB:
subroutine B code
……
……
Return
' Actual start of the main program
Main:
Gosub SubA
Gosub SubB
A subroutine must always end with a Return command.
