Search code examples
for-loopdelphicounter

for loop with two counters in Delphi


I'm new to Delphi so I apologize for the banality of my question.

How can I write in Delphi a for loop with two counters like this in C++:

int i, j;
for (i=0, j=0; j<100; i++, j++) {
//do something
}

Thanks


Solution

  • You have to "unroll" the loop like this:

    VAR I := 0;
    FOR VAR J:=0 TO 99 DO BEGIN
      // Do Something
      INC(I)
    END;