Appearance
While loop
While
Structure
while <Condition> do <Statement>
Example
Execute a statement while the condition is true
pascal
procedure ScriptEvent (var Value : variant);
begin
Value := 1;
while Value < 10 do
begin
LogInfo('Value is equal to '+IntToStr(Value));
Value := Value + 1;
end;
end;This example executes the LogInfo statement multiple times. Each time it also increments Value by 1. Eventually Value will no longer be less than 10 therefore processing will stop.
Description
The While loop is used to repeatedly execute a statement while a condition is true.
While loops nearly always contain multiple statements. The first statement (or multiple statements) does something, and then there is always another statement to increment the counter.