English
Language : 

NSB8 Datasheet, PDF (48/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
grifo®
GOSUB
ITALIAN TECHNOLOGY
STATEMENT:
GOSUB <line number>
ACTION:
The location of the statement immediately after the GOSUB statement is remembered by BASIC,
and program execution jumps to the specified line. GOSUB is used to execute a sequence of
statements, called a subroutine, elesewhere in the program. Execution will resume at the remembered
location if a RETURN statement is executed as part of the subroutine.
EXAMPLE PROGRAM:
10 REM illustration of subroutines.
20 PRINT “READY TO CALL SUBROUTINE”
30 GOSUB 1000
40 PRINT “WE ARE BACK!”
50 END
This example assumes that there also exists a subroutine beginning at line 1000 which sends the
message “NOW IN THE SUBROUTINE” to the terminal. if so, running the program produces the
following results:
READY TO CALL SUBROUTINE
NOW IN THE SUBROUTINE
WE ARE BACK
REMARKS:
A subroutine may be called while another is in progress. The only limit on this subroutine nesting
is the amount of memory available during program execution (remember that the location of the
return point takes memory space).
ERROR MESSAGES:
LINE NUMBER ERROR
OUT OF BOUNDS ERROR
See statement GOTO
SEE ALSO:
Statement RETURN
Statement GOTO
Section SUBROUTINES
Page 36
NSB8
Rel. 5.10