Programming instructions

34
Intermec Fingerprint 6.13 – Programmer's Guide
5. Intermec FINGERPRINT PROGRAMMING, cont'd.
IF...THEN...[ELSE]...ENDIF
It is possible to execute multiple THEN and ELSE statements. Each
statement must be entered on a separate line and the end of the
instruction must be indicated by ENDIF on a separate line, e.g.:
10 TIME$ = "121500":FORMAT TIME$ "HH:MM"
20 A%=VAL(TIME$)
30 IF A%>120000 THEN
40 PRINT "TIME IS ";TIME$("F"); ". ";
50 PRINT "GO TO LUNCH!"
60 ELSE
70 PRINT "CARRY ON - ";
80 PRINT "THERE'S MORE WORK TO DO!"
90 ENDIF
RUN
yields e.g.:
TIME IS 12:15. GO TO LUNCH!
GOTO
The most simple type of unconditional branching is the “waiting
loop”. This means that a program line branches the execution back
to itself, waiting for something to happen, for example a key being
pressed or a communication buffer becoming full.
This example shows how the program waits for the key F1 to be
pressed (line 30). Then a signal is emitted by the printer's buzzer:
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. This is useful when
you want create a waiting loop containing a number of lines, e.g.:
10 INPUT "Enter a number:", A%
20 IF A%<0 THEN GOTO 100 ELSE GOTO 200
30 GOTO 10
40 END
100 PRINT "NEGATIVE VALUE"
110 GOTO 40
200 PRINT "POSITIVE VALUE"
210 GOTO 40
RUN
GOTO in line 30 diverts the execution back to line 10 over and over
again until you type a value on the host (waiting loop). Depending
on whether the value is less than 0 or not, the execution branches
to one of two alternative lines (100 or 200), which print different
messages to the screen. In both cases, the execution branches to line
40, where the program ends. Line 20 is an example of conditional
branching, which is explained in chapter 5.8.
5. Conditional Instructions,
cont'd.
6. Unconditional
Branching
Keyboard Control
Also see:
Chapter 15.1