FOR (integer variant) v14
This form of
FOR creates a loop that iterates over a range of integer values. The variable
name is of type
INTEGER and exists only inside the loop. The two expressions giving the loop range are evaluated once when entering the loop. The iteration step is +1.
name begins with the value of
expression to the left of
.. and terminates when
name exceeds the value of
expression to the right of
... Thus the two expressions take on the roles
REVERSE clause specifies for the loop to iterate in reverse order. The first time through the loop,
name is set to the value of the right-most
expression. The loop terminates when the
name is less than the left-most
This example uses a
FOR loop that iterates from 1 to 10:
The following is the output after using the
If the start value is greater than the end value, the loop body doesn't execute. No error occurs, as shown by the following example:
This example has no output as the loop body never executes.
SPL also supports cursor
FOR loops. See Cursor FOR loop.