GOSUB
(Statement)

Call a subroutine.

GOSUB <labelname>

This statement calls a subroutine specified by <labelname>.
A subroutine can call other subroutines (nesting).

To return control from the subroutine called with GOSUB (ON...GOSUB) to the caller program, a RETURN statement should be used.

DIM li1 As Integer
|
|
IF li1 = 0 THEN
|
'If li1 is 0
|
STOP
|
'Stop program execution
|
ELSEIF li1 = 1 THEN
|
'If li1 is 1
|
GOTO *samp1
|
'Jump to the label *samp1
|
GO TO *samp2
|
'Jump to the label *samp2
|
ELSEIF li1 = 2 THEN
|
'If li1 is 2
|
GOSUB *samp3
|
'Call the subroutine beginning with the label name *samp3
|
ELSE
|
'If li1 is any other value
|
RETURN
|
'Return to the caller program
|
END IF
|
'Declare the end of the IF statement
|