Core.Actions.Loop.ForLoop
Classification
Name | ForLoop |
Short Description | For loop that is iterated until the counter reaches the final value. |
Class | Action |
Extension | OTX Core library |
Group | Core related actions |
Exceptions | - |
Checker Rules | - |
Standard Compliant | Yes |
OTL Syntax
for (IntegerVariable; IntegerTerm; IntegerTerm) : ForLoopName
{
...
}
Description
The OTX ForLoop activity contains a sequence of activities that are executed repeatedly until the Counter Variable reaches the Final Value. It is useful for iterating over arrays and for sequential processing.
At the Start of the loop, the expressions are calculated first by start and end value. Then, the counter variable is set to the initial value.
Before of each iteration, the counter variable is compared to the ending value. The counter variable exceeds the limit value, the loop is terminated, otherwise the iteration is performed. So, the loop is executed as long as the value of the counter variable is less than or equal to the ending value.
After each iteration, even after the last one, the counter variable to a value of 1 is increased. This applies even if the current iteration is stopped by a Continue activity. Only at the end of grinding through a Break activity, the value of the counter variable is not increased.
The Counter Variable can be used for any calculations inside and outside of the loop.
The loop can be exited about the activities of Break, Return, or Throw. The Continue activity stops the current iteration and continues with the next iteration, without having to leave the loop.
Properties
Name | Data Type | Class | Default | Cardinality | Description |
Counter | Integer | Variable | - | [1] | Counter variable of the loop |
Start | Integer | Term | - | [1] | Initial value of the loop |
End | Integer | Term | - | [1] | Ending value of the loop |
OTL Examples
Integer Integer1;
for (Integer1; 0; 9) : ForLoop1
{
Hmi.ConfirmDialog(Conversion.ToString(Integer1), null, @MessageTypes:INFO, null);
}