Programming instructions

40
Intermec Fingerprint 6.13 – Programmer's Guide
5. FINGERPRINT PROGRAMMING, cont'd.
9. Loops
Continued!
GOTO
One type of loop has already been described in connection with the
GOTO statement in chapter 5.6, where GOTO was used to refer to
the same line or a previous line. There are also two more advanced
type of loops:
FOR...NEXT
These statements are to used create loops, where a counter is
incremented or decremented until a specified value is reached. The
counter is defined by a FOR statement with the following syntax:
FOR<numeric variable>=<start value>TO<final value>[STEP<±interval>]
All program lines following the FOR statement will be executed
until a NEXT statement is encountered. Then the counter will be
updated according to the optional STEP value, or by the default
value +1, and the loop will be executed again. This will be repeated
until the final value, as specified by TO <final value>, is reached.
Then the loop is terminated and the execution proceeds from the
statement following the NEXT statement.
FOR...NEXT loops can be nested, i.e. a loop can contain another
loop etc. Each loop must have a unique counter designation in the
form of a numeric variable. The NEXT statement will make the
execution loop back to the most recent FOR statement. If you want
to loop back to a different FOR statement, the corresponding NEXT
statement must include the same counter designation as the FOR
statement.
This example shows how five lines of text entered from the keyboard
of the host can be printed with an even spacing:
10 FONT "SW030RSN"
20 FOR Y%=220 TO 100 STEP -30
30 LINE INPUT "Type text: ";TEXT$
40 PRPOS 100, Y%
50 PRTXT TEXT$
60 NEXT
70 PRINTFEED
80 END
RUN
Here is an example of two nested FOR...NEXT loops:
10 FOR A%=20 TO 40 STEP 20
20 FOR B%=1 TO 2
30 PRINT A%,B%
40 NEXT : NEXT A%
RUN
Yields:
20 1
20 2
40 1
40 2