Action Statement
Specify Action Statements to be repeated while a condition is true.
while BOOLEAN_VALUE loop [LOOP_NAME]
[ACTION_STATEMENT] ...
[ leave loop [LOOP_NAME] ]
[ACTION_STATEMENT] ...
end loop [LOOP_NAME]
BOOLEAN_VALUE
A boolean value or an expression that evaluates to a boolean value. An expression must be enclosed in parentheses.
loop LOOP_NAME
The identifier for a loop.
ACTION_STATEMENT
An action statement.
leave loop LOOP_NAME
Explicitly break out of (leave) the named loop. If you specify an outer loop, ESL leaves the specified outer loop and all inner loops. If you do not specify a name in the leave loop statement, ESL exits from the innermost loop that contains the leave loop statement, even if the innermost loop has a name.
Description
You can use a while loop statement within a response definition or an action routine definition. You can also specify it within a conditional action statement or within other loops, to any number of levels. You can specify blocks in loops, and vice versa. If you specify a block within a loop, execution of a leave loop statement causes all blocks contained in the loop to become inactive.
You specify both the condition and the actions in the while loop statement.
The while loop statement must end with the end loop keywords. The leave loop statement is optional.
ESL first evaluates the BOOLEAN_VALUE specified in the while clause. If the boolean value is true, ESL performs the action statements specified in the loop. When ESL reaches the end loop keywords, it evaluates the boolean once again. If the result is true, ESL returns to the top of the loop and performs the action statements again. This cycle continues for as long as the boolean value is true.
If the boolean value is false, during either the initial evaluation or a later evaluation, ESL ignores the loop and continues execution at the action statement (if any) immediately following the end loop statement. If the boolean is initially false, the loop will not be executed at all.
The identifier used to name the loop must be unique within the ESL program; there must be nothing else in the program with that name. Specifying a name in the while loop statement means that you must include a name in the end loop statement that exactly matches the name specified in the while loop statement.
If the program is compiled with External Strings, then any string literals used in this statement will be externalized.
Example
copy 1 to Count_IV
while (Count_IV <= 10) loop
add to Axes_GR
move 20 0
pattern Hashmark
copy (Count_IV + 1) to Count_IV
end loop
response to Help2_GR
while (Count_IV <= 5) loop
action Action_Sub
if (Action_flag_SV != "OK") then
leave loop
end if
copy (Count_IV + 1) to Count_IV
end loop
copy Action_flag_SV to Flag_log_SV
See Also
leave loop Action Statement
if Conditional Action Statement