BASIC FUNCTIONS
SECTION 5.8
5.8. 1
GOSUB
Function GOSUB causes execution to jump to a Basic subroutine
located elsewhere in the applications program.
Syntax GOSUB line number
GCSUB numeric expression
Examples GOSUB 150
causes program execution to jump to a subroutine located at
150.
The argument can also be an argument or expression, for
example:
GOSUB SI
or
GOSUB SI+100*A
This is illustrated by the program sequence:
10 INPUT A
20 SI=1
OOO
30 GCSUB SI+100*A
40 STOP
1000 PRINT "THIS IS SUBROUTINE 1
11
1010 RETURN
1100 PRINT ''THIS IS SUBROUTINE 2
11
1110 RETURN
etc.
If the number O is entered in line 10, the program will
perform subroutine 1. Input of the number 1 will cause
subroutine 2 to be executed.
Remarks A subroutine must always be terminated by a 'RETURN' state
ment. Program execution then continues from the statement
immediately after the GCSUB. GCSUB always requires a line
number as an argument.
VER. V09F PAGE 5 - 39