<<

Contents

Search

>>

 

FOR

 

 

Instruction

 

 

Syntax:

FOR <Variable> = <Start> TO <End> [STEP <Step>]

... Instructions ...

ENDLOOP

 

<Variable>

= <NUM-VARIABLE>

<Start>

= <NUM-EXPRESSION>

<End>

= <NUM-EXPRESSION>

<Step>

= <NUM-EXPRESSION>

 

 

Meaning:

Executes a serial of instructions in a loop, beginning at <Start> with the step width <Step> until <End>.

 

FOR loops can be nested any number of times. However, it is important that different run variables are used. Every instruction ENDLOOP refers to the innermost, not yet closed loop.

 

If <Start> is bigger than <End>, the loop is not executed.

 

<Step> can also be negative.

 

Parameter:

Variable

Numeric variable

Start

Start value

End

End value

Step

Step

 

Sample:

DIM FIELD(100,20)

FOR I% = 1 TO 100

    FOR J = 1 TO 20 STEP 2

        FIELD(I%,J) = I% * 1000 + J

    ENDLOOP

ENDLOOP

 

See also:

WHILE