Gosub...Return


Statement Gosub


Execute a subroutine


Syntax Gosub label


Remarks


GOSUB will transfer execution to the label referred to by label. Execution will continue from that point until the RETURN keyword is found or end of file is reached.

When RETURN is encountered, execution will resume on the line following the GOSUB.


See Also:

Goto Label


Example Script


NUMBER i


FOR i = 0 to 10

IF NOT ( i MOD 2 ) THEN

GOSUB Even_Number

ELSE

GOSUB Odd_Number

ENDIF

NEXT

PRINT "DONE"

END

:Even_Number

PRINT i;" is even."

RETURN

:Odd_Number

PRINT i;" is odd."

RETURN