EnglishРусский  
The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

for and fornum statements

for

The for statement consists of the for keyword, a sequence of three expressions separated by commas, a loop body.

for exp1, exp2, exp3
{
   ...
}

exp1 is an optional initialization expression. It is usually used for assigning the initial value to the counter variable.
exp2 is a conditional expression. The loop executes as long as the condition is TRUE.
exp3 is an optional increment expression. Actually, this expression increments or decrements the value of the counter.

The statement defined above can be performed with the help of the while loop as follows:

exp1
while exp2
{
   ...
   exp3
}

The following loops does the same actions.

for i=0, i<100, i++
{
   a += i
}

i = 0
for , i<100,
{
   a += i++
}

fornum

If the loop counter i is incremented by one and the highest value of the counter is defined before the loop iteration starts, the fornum statement is used in place of the for statement.

The fornum keyword is followed by a counter variable name, then the assignment operator and the expression (the initial value of the counter) can be used. If there are not any assignment operators, the initial value of the counter remains unchanged. Any integer should be treated as a counter variable. A comma delimited expression is specified,its result defines the loop termination. This expression is evaluated once before the loop iteration starts. The loop executes as long as the value of the counter is less than the value of the expression. Then the loop body follows. By default, the increment operation (value of the counter is incremented by one) is appended to the loop body by the compiler.

fornum i=0,100
{
   a += i
}

Related links