X1019 For loop control variable must be simple local variable (Delphi)
Go Up to Error and Warning Messages (Delphi)
This error message is given when the control variable of a for statement is not a simple variable (but a component of a record, for instance), or if it is not local to the procedure containing the for statement.
For backward compatibility reasons, it is legal to use a global variable as the control variable - the compiler gives a warning in this case. Note that using a local variable will also generate more efficient code.
program Produce; var I: Integer; A: array [0..9] of Integer; procedure Init; begin for I := Low(A) to High(a) do (*<-- Warning given here*) A[I] := 0; end; begin Init; end. program Solve; var A: array [0..9] of Integer; procedure Init; var I: Integer; begin for I := Low(A) to High(a) do A[I] := 0; end; begin Init; end.