Intermec PB32 Fingerprint Developer's Guide (old) - Page 35

Using an ON...GOSUB Instruction, Using an ON...GOTO Instruction, Using an ON BREAK...GOSUB

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187

Chapter 2 — Understanding Fingerprint Syntax
Intermec Fingerprint Developer’s Guide
19
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
INPUT “Press key 1, 2, or 3 on host: ”, A%
20
ON A% GOSUB 1000, 2000, 3000
30
END
1000
PRINT “You have pressed key 1”: RETURN
2000
PRINT “You have pressed key 2”: RETURN
3000
PRINT “You have pressed key 3”: RETURN
RUN
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
INPUT “Press key 1, 2, or 3 on host: ”, A%
20
ON A% GOTO 1000, 2000, 3000
30
END
1000
PRINT “You have pressed key 1”: GOTO 30
2000
PRINT “You have pressed key 2”: GOTO 30
3000
PRINT “You have pressed key 3”: GOTO 30
RUN
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
BREAK 1,35
20
BREAK 1 ON
30
ON BREAK 0 GOSUB 1000:REM Break from keyboard
40
ON BREAK 1 GOSUB 1000:REM Break from host (#)
50
GOTO 50
60
SOUND 800,100
70
BREAK 1 OFF: END
1000
FOR A%=1 TO 3
1010
SOUND 440,50
1020
SOUND 349,50
1030
NEXT A%
1040
GOTO 60
RUN