17.08.2013 Views

Contents, cont'd. - Intermec

Contents, cont'd. - Intermec

Contents, cont'd. - Intermec

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Chapter 2 Program Instructions<br />

Field of Application Statement for creating a loop in the program execution, where a counter<br />

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

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

1 2 3<br />

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

1<br />

2<br />

3<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. Each<br />

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

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

2<br />

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. If<br />

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

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

FOR...NEXT loops can be nested, i.e. a loop can contain another loop etc.<br />

However, each loop must have a unique counter designation and the inside<br />

loop must be concluded by a NEXT statement before the outside loop can be<br />

executed.<br />

Example The counter A% is incremented from 20 to 100 in steps of 20 by means of a<br />

FOR...NEXT loop:<br />

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

20 PRINT A%<br />

30<br />

RUN<br />

NEXT<br />

20<br />

40<br />

60<br />

80<br />

100<br />

yields<br />

<strong>Intermec</strong> Fingerprint 7.2 – Reference Manual Ed. 3 81

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

Saved successfully!

Ooh no, something went wrong!