Table of Contents

Advertisement

GOSUB
{
Function:
Branched
line
No.
}
Line No.
#program area No.
Number 0 to 9
Performs a branching to a specified subroutine.
Parameter:
Line No.
:
Program
area No.
:
Explanation:
1
to 9999
.
0
to 9.
6-2 Program Commands
®
1) Performs a branching to a subroutine. A return from this subroutine is per-
formed by executing RETURN
.
2) To make a subroutine inside a subroutine is called nesting which can be
performed with up to 8
levels.
3) Return to the statement next to the GOSUB statement is performed by
RETURN
.
4) Return to the main routine cannot be performed by an IF statement or
GOTO statement. Therefore, be sure to perform return by a
RETURN
state-
ment.
5) When the branched line No
.
does not exist, an error (Error 4) occurs.
*A
numeric expression can also be used for a branched line number and a
pro-
gram area number.
Example:
10 PRINT "MAIN 10"
20 GOSUB 100
30
PRINT
''MAIN
30''
40
END
100 PRINT "SUB 100"
110 GOSUB 200
120 RETURN
200 PRINT ''SUB 200"
210 RETURN
121

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents