DO with Iteration Count

 
<group>                 ::= <group head> <ending>

<group head>            ::= DO <step definition> ;
                          | <group head> <statement>

<step definition>       ::= <variable> <replace> <expression> <iteration control> 

<iteration control>     ::= TO <expression>
                          | TO <expression> BY <expression>

<ending>                ::= END
                          | END <identifier>
                          | <label definition> <ending>
  
 
This form of the DO statement provides execution of a group of statements a specified number of times. All expressions are evaluated before the first iteration and cannot be changed within the loop. The <variable> is initialized to the value of the first <expression>. Before each iteration its value is compared to the value of the to expression. When its value of the variable is greater, control passes to the statement following END. The variable is incremented by the by expression, or by one if the by expression is omitted, following each execution of the loop body.

Negative steps are not allowed; the value of the by expression should evaluate to a positive integer.

Example:


do i=1 to 5;
  output = 'The value is ' || i;
end;