For field value

Command group Flag affected Reversible Execute on client Platform(s)
Constructs NO NO YES All

Syntax

For field-name from start to stop step step

Description

This command marks the beginning of a For loop which defines a series of commands to be repeated a number of times. You use field-name as a counter that is automatically incremented by the step value each time the End For statement is reached.

The values involved must all be numbers, preferably integers. If start value is greater than end value, and step value is positive, the command will perform no loops. Similarly, no loops are performed if start value is less than end value, and step value is negative.

The end value is evaluated once at the start of the loop, and saved, for performance reasons, so changing the end value during the loop will have no effect. You can use Jump to start of loop within the loop to continue the next iteration of the loop. Similarly, you can terminate the loop early using Break to end of loop if desired.

Example

Calculate lString as  ''
For lCount from 0 to 9 step 1
  Calculate lString as con(lString,lCount)
End For
OK message {String=[lString]} ## shows 'String=0123456789'
Calculate lString as ''
For lCount from 9 to 0 step -1
  Calculate lString as con(lString,lCount)
End For
OK message {String=[lString]} ## shows 'String=9876543210'