For Statement

Acts as a loop that repeats the statements in StatSeq until Ident is greater than Expr2. Expr1 and Expr2 are expressions of type number. Ident is a variable of type number. The first time the loop is entered, Ident is set to Expr1. Ident is incremented by 1 each time the loop is executed. Expr2 is only evaluated the first time the loop is entered.

Syntax

Stat = "for" [Ident | "var" Ident] ":=" Expr1 "to" Expr2 "do" StatSeq "end".

The for loop is equivalent to the following while loop:

Example

dcltrans
  transaction t1
  const
    MAX_IND := 100;
  var
    I : number;
    a : array [MAX_IND] of number;
  begin
    ...
    for I := 1 to MAX_IND do
      a[i] := i;
    end;
  end t1;