Intermec PC43d Fingerprint Developer's Guide (PC23d, PC43d/t, PM23c, PM43, PM4 - Page 30
Instructions for Conditional Branching, Using an IF...THEN GOTO...ELSE Instruction, Using an ON...
View all Intermec PC43d manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 30 highlights
Chapter 2 - Understanding Fingerprint Syntax 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 Using an ON...GOSUB Instruction Depending on the value of a numeric expression, the execution branches to one of several subroutines. If the value is 1, the program branches to the first subroutine in the instruction, if the value is 2 it branches to the second subroutine, and so on. The next example includes such an instruction: 10 20 30 1000 2000 3000 RUN INPUT "Press key 1, 2, or 3 on host: ", A% ON A% GOSUB 1000, 2000, 3000 END PRINT "You have pressed key 1": RETURN PRINT "You have pressed key 2": RETURN PRINT "You have pressed key 3": RETURN Using an ON...GOTO Instruction This instruction is similar to ON...GOSUB but the program branches to specified lines instead of subroutines. This implies that you cannot use RETURN statements to go back to the main program. 18 Fingerprint Developer's Guide