Embarcadero Delphi For Loops


  • for OrdinalVariable := LowerOrdinalValue to UpperOrdinalValue do begin {loop-body} end;
  • for OrdinalVariable := UpperOrdinalValue downto LowerOrdinalValue do begin {loop-body} end;
  • for EnumerableVariable in Collection do begin {loop-body} end;


  • Delphi's for-loop syntax does not provide anything to change step amount from 1 to any other value.
  • When looping with variable ordinal values, e.g. local variables of type Integer, the upper and lower values will be determined only once. Changes to such variables will have no effect on the loops iteration count.