9.2.3.3. For statements. The for statement indicates that a statement is to be repeatedly executed while a progression of values is assigned to a variable that is called the control variable of the for statement. 

ForStatement = "for" ControlVariable ":=" InitialValue ( "to" I "downto" ) FinalValue "do" Statement . ControlVariable = Variableldentifier. InitialValue = OrdinalExpression . FinalValue = OrdinalExpression . 

The control variable must be local to the block (see Section 10.2) whose statement part contains the for statement, and must possess an ordinal type that is compatible with the types of the initial value and final value. 

A statement s is said to threaten a variable v if any of the following conditions are true. 

(a) s is an assignment statement that assigns to v. 

(b) s contains v occurring as an actual variable parameter (see section 11.3.2.2). 

(c) s is a procedure statement that activates the predeclared procedure read or readln and v is one of its actual parameters. 

(d) s is a for statement and v is its control variable. 

No statement inside the for statement must threaten the control variable. also, no procedure or function declared local to the block in which the control variable is declared may contain a statement that threatens the control variable. these rules ensure that the repeated statement cannot alter the value of the control variable. 

Let tl and t2 be new variables (not otherwise accessible) possessing the same type as v, and let p be a new variable possessing type Boolean. then with the exceptions noted in comments, the following equivalences hold. 

for v := el to e2 do s 

is equivalent to 

begin Tl .= el; T2 := e2; if Tl <= T2 then begin 

