Intermec PB51 Fingerprint Developer's Guide (old) - Page 37

Unconditional Branching Using a GOTO Statement, Branching to an Error-Handling Subroutine

Page 37 highlights

Chapter 2 - Understanding Fingerprint Syntax Unconditional Branching Using a GOTO Statement The simplest type of unconditional branching is the waiting loop, which means that a program line branches the execution to itself and waits for something to happen, such as a keypress. This example shows how the program waits for the F1 key to be pressed (line 30). When the key is pressed, the printer beeps: 10 20 30 40 1000 1010 RUN ON KEY (10) GOSUB 1000 KEY (10) ON GOTO 30 END SOUND 880,100 END It is also possible to branch to a different line, as in this example: 10 INPUT "Enter a number: ", A% 20 IF A%

  • 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
21
Unconditional Branching Using a GOTO Statement
The simplest type of unconditional branching is the waiting loop, which means that
a program line branches the execution to itself and waits for something to happen,
such as a keypress.
This example shows how the program waits for the
F1
key to be pressed (line 30).
When the key is pressed, the printer beeps:
10
ON KEY (10) GOSUB 1000
20
KEY (10) ON
30
GOTO 30
40
END
1000
SOUND 880,100
1010 END
RUN
It is also possible to branch to a different line, as in this example:
10
INPUT “Enter a number: ”, A%
20
IF A%<0 THEN GOTO 100 ELSE GOTO 200
30
END
100
PRINT “NEGATIVE VALUE”
110
GOTO 30
200
PRINT “POSITIVE VALUE”
210
GOTO 30
RUN
Depending on whether the value you enter from the host is less than 0 or not, the
execution branches to one of two lines (100 or 200), which print different messages
to the screen. In either cases, the execution branches to line 30, where the program
ends.
There are more elegant ways to create such a program, but this example illustrates
how GOTO always branches to a specific line. Line 20 is an example of conditional
branching. For more information, see
“Instructions for Conditional Branching”
on page 18.
The GOTO statement can also be used to resume program execution at a specified
line after a STOP statement.
Branching to an Error-Handling Subroutine
Two instructions are used to branch to and from an error-handling subroutine
when an error occurs.
Using an ON ERROR GOTO Instruction
ON ERROR GOTO branches the execution to a specified line when an error occurs,
ignoring the standard error-trapping routine. If the line number is specified as 0, the
standard error-trapping routine is used.
Resuming Execution After Error Handling
Use a RESUME statement to resume execution after an error-handling subroutine
has been executed. RESUME is only used in connection with ON ERROR GOTO
statements and can be used as follows:
RESUME or RESUME 0 - Execution is resumed at the statement where the error
occurred.