For Loop
The For Loop statement is used to repeatedly execute a statement a set number of times.
The counter should be a simple Integer variable which has been declared earlier in the script.
While it is common practice to declare this counter variable using the code var i : integer with the variable simply given the name of i, in reality any name can be assigned to this variable.
The statement or group of statements within a Begin….End block is executed the number of times specified by the InitialValue and LastValue.
For Loop has the structure for <counter> := <InitialValue> to <LastValue> do <Statement>
Execute A Single Statement Multiple Times
procedure ScriptEvent (var Value : variant);begin for i := 1 to 10 do LogInfo('This is the '+IntToStr(i)+' execution of this statement');end;This example executes a single LogInfo statement 10 times.
Execute Multiple Statements Multiple Times
procedure ScriptEvent (var Value : variant);begin for i := 1 to 10 do begin LogInfo('This is the '+IntToStr(i)+' execution of this statement'); LogInfo('This is the next statement to run each time'); end;end;This example executes two LogInfo statements 10 times each.