The statement block is repeated endlessly. The number of iterations in the statement block is not checked, there is no expression to evaluate.
// Exit according to an IF condition
LOOP
// Read a line in the text file
ALine = fReadLine(FileNum)
IF ALine = EOT THEN BREAK
ProcessLine(ALine)
END
// Exit according to a WHILE condition
LOOP
// Read a line in the text file
ALine = fReadLine(FileNum)
ProcessLine(ALine)
DO WHILE ALine <> EOT
// Exit according to an iteration
LOOP (10)
// Read a line in the text file
ALine = fReadLine(FileNum)
ProcessLine(ALine)
END
Syntax
Loop with exit according to an "IF" condition Hide the details
LOOP
...
IF <Condition> THEN BREAK
...
END
<LOOP>:
Marks the beginning of the statement block.
<BREAK>:
Used to exit from the statement block.
<END>:
Marks the end of the statement block.
Loop with exit according to a "WHILE" condition Hide the details
LOOP
...
DO WHILE <Condition>
<LOOP>:
Marks the beginning of the statement block.
<DO WHILE>:
Marks the end of the statement block. Used to exit from the statement block. The lines of the loop found before this statement are run.
Loop with exit according to the number of iterations Hide the details
LOOP (<Number of iterations>)
...
END
<LOOP>:
Marks the beginning of the statement block.
<Number of Iterations>:
Number of iterations to perform. The program will exit the loop when the number of iterations is reached.
<END>:
Marks the end of the statement block.
Remarks
The code to be executed is placed between the LOOP and END statements.
Several statements are available:
- RETURN: Exit the loop and the current process (or procedure).
- RETURN: Return a status report to the calling process. Exit the loop and the current process (or procedure).
- BREAK: Exit from the loop and run the rest of the current process.
Close is used to exit from the loop and to close the current window.
Caution:
RETURN and
RETURN cannot be used
in the same process.
Running the next iteration
To directly run the next iteration
without ending the code of the current iteration, use the
CONTINUE statement:
LOOP
...
IF <Condition> THEN CONTINUE // Go back to the LOOP keyword
...
END
During the compilation of the project, an endless loop (no
BREAK,
RETURN or
RETURN) is signaled by a warning.
External variable in a loop
A variable declared by
EXTERN cannot be used in a loop.