Contents Up << >>

Loop statement

The loop statement executes a block of sequential statements repeatedly 0 or more times. Each execution of the statement list is called an iteration. The syntax of the loop statement is If the label appears at the end of the statement, it must be the same as the label at the beginning of the loop. If the loop statement does not have an iteration scheme, then the statement list will be executed repeatedly forever unless the statement list contains a wait or exit statement.

The iteration scheme can take one of two forms given by the following rule:

The first form contains a boolean expression that controls the number of iterations that are performed. Before each iteration (including the first) the condition is evaluated. If it is true, then the statement list is executed, and if it is false, the loop statement is complete.

The second form contains a discrete range that specifies how many iterations to perform. The simple name is the name of a constant that is implicitly declared within the scope of the loop statement. The constant is initially equal to the left-most value in the discrete range. At the end of each iteration, the constant is set to the next value in the discrete range. One iteration is performed for each value in the discrete range. If the discrete range is empty, then the statement list is executed zero times.