You can specify loops within other loops, to any number of levels. The following example illustrates the use of loop names in nested loops, and shows how you can specify a conditional action statement within a loop.
response to ...
copy 1 to Int
while (Int <= 5) loop Count # Outer loop
for Action_num = 1 to 10 loop Action #Inner loop
action Action_sub
if (Action_flag = "OK") then # Conditional
send Action_flag to Recorder # action
action Logit # statement
else
leave loop Count
end if
end loop Action # End of inner loop
copy (Int + 1) to Int
end loop Count # End of outer loop
ESL performs the entire Count loop repeatedly, until the value of Int exceeds 5 and thus the first boolean expression is false. Within the Count loop, ESL performs a second loop, named Action. The statements in this loop are performed repeatedly, until the value of Action_num exceeds 10. The Action loop is performed 10 times in each iteration of the Count loop, for a total of 50 times.
Within the Action loop, each time through the loop, ESL performs the conditional action statement that begins with the if statement:
if (Action_flag = "OK") then
Depending on the value of this expression, ESL performs the action statements in either the then or the else clause.
After completing each cycle of the Action loop, ESL returns to the top of the Action loop, increments Action_num and checks to see if the value of Action_num is not greater than 10, and performs the loop again. This cycle continues until the value of Action_num is greater than 10. At this point, ESL transfers to the statement following the Action loop:
copy (Int + 1) to Int
After executing these statements, ESL returns to the top of the Count loop and evaluates the boolean expression (Int <= 5) again. If the value of Int does not exceed the value of 5, ESL performs the entire loop again.