Programming instructions
Intermec Fingerprint v7.61 – Programmer’s 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 "You’re back in the main program"
40 END
1000 PRINT "This is subroutine 1"
1010 GOSUB 2000
1020 PRINT "You’re back from subroutine 2 to 1"
1030 RETURN
2000 PRINT "This is subroutine 2"
2010 GOSUB 3000
2020 PRINT "You’re back from subroutine 3 to 2"
2030 RETURN
3000 PRINT "This is subroutine 3"
3010 PRINT "You’re leaving subroutine 3"
3020 RETURN
RUN
yields:
This is the main program
This is subroutine 1
This is subroutine 2
This is subroutine 3
You’re leaving subroutine 3
You’re back from subroutine 3 to 2
You’re back from subroutine 2 to 1
You’re back in the main program
Ok