02.10.2012 Views

Programmer's Reference Manual Intermec Fingerprint® v8.70.0 ...

Programmer's Reference Manual Intermec Fingerprint® v8.70.0 ...

Programmer's Reference Manual Intermec Fingerprint® v8.70.0 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FOR...TO...NEXT<br />

<strong>Intermec</strong> Fingerprint <strong>v8.70.0</strong>/v10.0.0 Programmer´s <strong>Reference</strong> <strong>Manual</strong><br />

Chapter —Program Instructions<br />

Purpose Statement for creating a loop in the program execution, where a counter is<br />

incremented or decremented until a specified value is reached.<br />

Syntax FOR=TO[STEP]NEXT[]<br />

is the variable to be used as a counter.<br />

is the initial value of the counter.<br />

is the final value of the counter.<br />

is the value of the increment (decrement).<br />

Remarks This statement is always used in connection with a NEXT statement.<br />

The counter () is given an initial value by the numeric expression<br />

(). If no increment value is given (STEP ), the value 1 is<br />

1 3<br />

assumed. A negative increment value will produce a decremental loop.<br />

Each time the statement NEXT is encountered, the loop will be executed<br />

again until the final value, specified by (), is reached. Then the<br />

2<br />

execution will proceed from the first line after the NEXT statement.<br />

If the optional variable is omitted in the NEXT statement, the program<br />

execution will loop back to the most recently encountered FOR statement.<br />

If the NEXT statement does include a variable, the execution will loop<br />

back to the FOR statement specified by the same variable.<br />

FOR...NEXT loops can be nested, which means that a loop can contain<br />

another loop, etc. However, each loop must have a unique counter designation<br />

and the inside loop must be concluded by a NEXT statement<br />

before the outside loop can be executed.<br />

Examples The counter A% is incremented from 10 to 50 in steps of 20:<br />

10 FOR A%=10 TO 50 STEP 20<br />

20 PRINT A%<br />

30 NEXT<br />

RUN<br />

10<br />

30<br />

50<br />

The counter B% is decremented from 50 to 10 in steps of 20:<br />

10 FOR A%=50 TO 10 STEP -20<br />

20 PRINT A%<br />

30 NEXT<br />

RUN<br />

50<br />

30<br />

10<br />

yields:<br />

yields:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!