Intermec PB51 Fingerprint Developer's Guide (old) - Page 34
Instructions for Conditional Branching, Using an IF...THEN GOTO...ELSE Instruction
View all Intermec PB51 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 34 highlights
Chapter 2 - Understanding Fingerprint Syntax • background communication is interrupted. You can also branch to a subroutine from different places in the same program. You only need to write the routine once, making the program more compact. The instruction for unconditional branching to subroutines is the GOSUB statement. After branching, the subroutine is executed line by line until a RETURN statement is encountered. The same subroutine can be branched to as often as needed from different lines in the main program. GOSUB remembers where the last 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. Subroutines should be placed on lines with higher numbers than the main program. Append the main program with an END statement to avoid unintentional execution of subroutines. The next example illustrates nested subroutines: 10 20 30 40 1000 1010 1020 1030 2000 2010 2020 2030 3000 3010 3020 RUN PRINT "This is the main program" GOSUB 1000 PRINT "You're back in the main program" END PRINT "This is subroutine 1" GOSUB 2000 PRINT "You're back from subroutine 2 to 1" RETURN PRINT "This is subroutine 2" GOSUB 3000 PRINT "You're back from subroutine 3 to 2" RETURN PRINT "This is subroutine 3" PRINT "You're leaving subroutine 3" RETURN Instructions for Conditional Branching Conditional branching means that the program execution branches to a certain line or subroutine when a specified condition is met. The following instructions are used for conditional branching: Using an IF...THEN GOTO...ELSE Instruction If a specified condition is TRUE, the program branches to a certain line, but if the condition is FALSE, something else is done as shown in the next example: 10 INPUT "Enter a value: ",A% 20 INPUT "Enter another value: ",B% 30 IF A%=B% THEN GOTO 100 ELSE PRINT "NOT EQUAL" 40 END 100 PRINT "EQUAL" 110 GOTO 40 RUN 18 Intermec Fingerprint Developer's Guide