Intermec PM4i Fingerprint Developer's Guide (old) - Page 35
Using an ON...GOSUB Instruction, Using an ON...GOTO Instruction, Using an ON BREAK...GOSUB
View all Intermec PM4i manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 35 highlights
Chapter 2 - Understanding Fingerprint Syntax 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. ON...GOTO is shown in this example: 10 20 30 1000 2000 3000 RUN INPUT "Press key 1, 2, or 3 on host: ", A% ON A% GOTO 1000, 2000, 3000 END PRINT "You have pressed key 1": GOTO 30 PRINT "You have pressed key 2": GOTO 30 PRINT "You have pressed key 3": GOTO 30 Using an ON BREAK...GOSUB Instruction When a BREAK condition occurs on a specified device, the execution is interrupted and branched to a specified subroutine. For example, the program can make the printer emit a sound or display a message before the program is terminated. You can also let the program execution continue along a different path. In the next example, the program is interrupted when the Shift and Pause keys on the printer keyboard are pressed. The execution branches to a subroutine, which emits a siren-sounding signal three times. Then the execution returns to the main program, which is indicated by a long shrill signal. 10 20 30 40 50 60 70 1000 1010 1020 1030 1040 RUN BREAK 1,35 BREAK 1 ON ON BREAK 0 GOSUB 1000:REM Break from keyboard ON BREAK 1 GOSUB 1000:REM Break from host (#) GOTO 50 SOUND 800,100 BREAK 1 OFF: END FOR A%=1 TO 3 SOUND 440,50 SOUND 349,50 NEXT A% GOTO 60 Intermec Fingerprint Developer's Guide 19