Statement FOR Foundation
Iteratively executes a program loop up to a maximum count.
FOR <CounterVar> := <nStart> TO <nEnd> [STEP <nStep>] <SourceCode>... [EXIT] <SourceCode>... [LOOP] <SourceCode>... NEXT
The FOR..NEXT control structure defines a block of program statements which is continuously executed until the value of the variable <CounterVar> has exceeded the value of the expression <nEnd>. When the program hits the NEXT statement, it begins again with the FOR statement and evaluates all expressions in this line. That means that within a FOR...NEXT loop, the value of the variable <CounterVar> and/or the value of the expressions <nEnd> and <nStep> can be changed. <nStart> cannot be changed since this value is assigned to the counter variable at the initial entry into the loop. If a LOOP statement is executed within the FOR..NEXT body, the loop begins again without executing source code between LOOP and NEXT. By using the EXIT statement, the loop can be immediately exited without <CounterVar> changing again. In this case, the program continues at the first executable program line following NEXT.
The beginning value <nStart> can be greater than the end value <nEnd>. In this case, STEP must be defined with a negative value and the variable <CounterVar> is decremented until it reaches the value of <nEnd>.
FOR...NEXT loops can be nested and can contain other control structures except BEGIN SEQUENCE in connection with the RECOVER statement. Within the BEGIN SEQUENCE..RECOVER control structure, no LOOP or EXIT statement is permitted.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.