Programming instructions
Intermec Fingerprint v7.61 – Programmer’s Reference Manual Ed. 7 93
Chapter 2 Program Instructions
FOR...TO...NEXT
Field of Application
Statement for creating a loop in the program execution, where a counter
is incremented or decremented until a specifi ed value is reached.
Syntax FOR<nvar>=<nexp
1
>TO<nexp
2
>[STEP<nexp
3
>]NEXT[<nvar>]
<nvar> is the variable to be used as a counter.
<nexp
1
> is the initial value of the counter.
<nexp
2
> is the fi nal value of the counter.
<nexp
3
> is the value of the increment (decrement).
Remarks
This statement is always used in connection with a NEXT statement.
The counter (<nvar>) is given an initial value by the numeric expression
(<nexp
1
>). If no increment value is given (STEP <nexp
3
>), the value 1 is
assumed. A negative increment value will produce a decremental loop. Each
time the statement NEXT is encountered, the loop will be executed again until
the fi nal value, specifi ed by (<nexp
2
>), is reached. Then the execution will
proceed from the fi rst line after the NEXT statement.
If the optional variable is omitted in the NEXT statement, the program
execution will loop back to the most recently encountered FOR statement.
If the NEXT statement does include a variable, the execution will loop back
to the FOR statement specifi ed by the same variable.
FOR...NEXT loops can be nested, which means that a loop can contain
another loop, etc. However, each loop must have a unique counter designation
and the inside loop must be concluded by a NEXT statement before the
outside loop can be executed.
Example
The counter A% is incremented from 20 to 100 in steps of 20 by means
of a FOR...NEXT loop:
10 FOR A%=20 TO 100 STEP 20
20 PRINT A%
30 NEXT
RUN
yields:
20
40
60
80
100