For                                                                                                          Statement

 

FOR varName=startValue TO endValue [STEP stepValue]

 

Description

Defines the beginning of a repeated set of statements. The end of the repeated set of statements is defined by the NEXT statement. varName is initially set to the startValue and incremented by the optional stepValue on each repetition of the sequence. If stepValue is not specified, then a stepValue of 1 is used. The execution of the set of repeated statements ends when the value of varName is greater than endValue. At that point, the next statement executed is the statement following the NEXT statement. In the set of repeated statements an EXIT FOR statement immediately cancels the execution of the set of repeated statements and transfers control to the statement following the NEXT statement. StepVal may be a positive or negative value.

 

Example

For i=1 to 5

  .........

Next

 

For cnt=cntMax to 1 step -1

  .........

  if total > 5000 then

    Exit For

  End if

  .........

next