Intermec PM43/PM43c Fingerprint Developer's Guide (PC23d, PC43d/t, PM23c, PM43 - Page 32

Using an ON KEY...GOSUB Instruction, Unconditional Branching Using a GOTO Statement

Page 32 highlights

Chapter 2 - Understanding Fingerprint Syntax Using an ON KEY...GOSUB Instruction To use the printer keypad, each key can be enabled individually using a KEY ON statement and assigned to a subroutine using an ON KEY GOSUB statement. The subroutine should contain the instructions you want performed when the key is pressed. In the statements KEY () ON, KEY () OFF, and ON KEY () GOSUB..., the keys are specified by id. numbers enclosed by parentheses. For more information, see "Using the Printer Keypad" on page 109. Note that ON KEY...GOSUB excludes data input from the printer keypad. This example shows how the two unshifted keys F1 (ID 10) and F2 (ID 11) are used to change the printer contrast: 10 20 30 40 50 60 70 80 90 100 110 120 1000 1010 1020 2000 2010 2030 RUN PRPOS 100,500 PRLINE 100,100 FONT "Univers" PRPOS 100,300 MAG 4,4 PRTXT "SAMPLE" ON KEY (10) GOSUB 1000 ON KEY (11) GOSUB 2000 KEY (10) ON : KEY (11) ON GOTO 70 PRINTFEED END SETUP "MEDIA,CONTRAST,-10%" PRPOS 100,100 : PRTXT "Weak Print" RETURN 110 SETUP "MEDIA,CONTRAST,10%" PRPOS 100,100 : PRTXT "Dark Print" RETURN 110 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

Chapter 2 — Understanding Fingerprint Syntax
20
Fingerprint Developer’s Guide
Using an ON KEY...GOSUB Instruction
To use the printer keypad, each key can be enabled individually using a KEY ON
statement and assigned to a subroutine using an ON KEY GOSUB statement. The
subroutine should contain the instructions you want performed when the key is
pressed.
In the statements KEY (<id.>) ON, KEY (<id.>) OFF, and ON KEY (<id.>) GOSUB...,
the keys are specified by id. numbers enclosed by parentheses. For more
information, see
“Using the Printer Keypad” on page 109
.
Note that ON KEY...GOSUB excludes data input from the printer keypad.
This example shows how the two unshifted keys
F1
(ID 10) and
F2
(ID 11) are used
to change the printer contrast:
10
PRPOS 100,500
20
PRLINE 100,100
30
FONT “Univers”
40
PRPOS 100,300
50
MAG 4,4
60
PRTXT “SAMPLE”
70
ON KEY (10) GOSUB 1000
80
ON KEY (11) GOSUB 2000
90
KEY (10) ON : KEY (11) ON
100
GOTO 70
110
PRINTFEED
120
END
1000
SETUP “MEDIA,CONTRAST,-10%”
1010
PRPOS 100,100 : PRTXT “Weak Print”
1020
RETURN 110
2000
SETUP “MEDIA,CONTRAST,10%”
2010
PRPOS 100,100 : PRTXT “Dark Print”
2030
RETURN 110
RUN
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