Embarcadero Delphi For Loops

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • 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;

Remarks

  • 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.


Got any Embarcadero Delphi Question?