Syntax
The while
syntax can be expressed as follows:
for <variable name> while <condition>
{
<instructions>
}
for <variable name> while <condition>
<instruction>
- You can declare the variable at the beginning of the script. The variable of the loop must be an integer:
let i(Integer)
for i = 2 while i<50
{
//EKL Actions
}
- You can initialize the variable with an instruction that returns an Integer. The variable of the loop must be an integer:
let i(Integer)
for i = 2*2+1 while i<50
{
//EKL Actions
}
Example 1
In the script below, the loop executes until an expression becomes
false.
let i = 1
let x(Point)
for i while i <=parameter.Size()
{
x = parameter.GetItem(i)
if (x.GetAttributeReal(Y) < 0.04)
x.SetAttributeReal(Y,0.04)
}
where:
i
is a variable name of integer type. It is incremented at the end of
each execution of the body.
X
is a variable for points.
Example 2
If the variable is incremented by the user, there is no more automatic increment (automatic increment is an increment of 1 for each loop).
let i = 1
for i while i <=11
{
Message(i)
i=i+3
}
Returns messages 1,4,7 and 10. Adding i=i+3 stops the automatic increment and replaces it.