Programming instructions

Intermec Fingerprint v7.61 Programmers Reference Manual Ed. 7112
Chapter 2 Program Instructions
GOSUB
Field of Application
Statement for branching to a subroutine.
Syntax GOSUB<ncon>|<line label>
<ncon>|<line label> is the number or label of the first line in the desired
subroutine.
Remarks
After branching, the subroutine will be executed line by line until a RETURN
statement is encountered.
The same subroutine can be branched to many times from different lines
in the main program. GOSUB always remembers where the branching
took place, which makes it possible to return to the correct line in the main
program after the subroutine has been executed.
Subroutines may be nested, which means that a subroutine may contain a
GOSUB statement for branching to a secondary subroutine and so on until
the printer runs out of memory.
Subroutines are normally placed on program lines with higher numbers
than the main program. The main program should be appended by an END
statement to avoid unintentional execution of subroutines.
Example
This example makes use of line numbers:
10 PRINT "This is the main program"
20 GOSUB 1000
30 PRINT "Youre back in the main program"
40 END
1000 PRINT "This is subroutine 1"
1010 GOSUB 2000
1020 PRINT "Youre back from subroutine 2 to 1"
1030 RETURN
2000 PRINT "This is subroutine 2"
2010 GOSUB 3000
2020 PRINT "Youre back from subroutine 3 to 2"
2030 RETURN
3000 PRINT "This is subroutine 3"
3010 PRINT "Youre leaving subroutine 3"
3020 RETURN
RUN
yields:
This is the main program
This is subroutine 1
This is subroutine 2
This is subroutine 3
Youre leaving subroutine 3
Youre back from subroutine 3 to 2
Youre back from subroutine 2 to 1
Youre back in the main program
Ok