The EGL for statement
runs a set of statements in a loop that iterates until a counter reaches
a specified value. You provide an initial and limiting value for the
counter, as well as a value for increasing or decreasing the counter
value after each iteration.
Syntax
- counter
- A integer value for the counter. EGL statements embedded in the for statement
can change the value of counter.
You can
declare a variable for counter in the for statement,
in which case the scope of the variable is the for statement.
A later example demonstrates this usage.
- delta
- The integer value that EGL uses to change counter at
the end of each iteration and before testing the counter value.
The default is 1.
EGL statements embedded in the for statement
can change the value of delta.
- decrement
- The keyword indicates that the value of counter is
reduced by the value of delta after each
iteration. By default, EGL increases the value of counter instead.
- finish
- The final counter value for which a
loop iteration occurs. The value is of an integer type.
EGL statements
within the for statement can change the
value of finish.
- label
- A label that a continue or exit statement
can reference.
- start
- The initial value of counter. The value
is of an integer type. The default value is 1.
- statement
- An EGL statement.
After the following code runs, the value
of
sum is 30:
inputList int[] = [2,4,6,8,10];
sum int = 0;
numberInList int = inputList.getSize();
for (i int from 1 to numberInList by 1)
sum = inputList[i] + sum;
end
Compatibility
Table 1. Compatibility
Target |
Issue |
Java |
No issues |
JavaScript |
No issues.
|