LOOP,UNTIL,WHILE,REPEAT
ANSI
The LOOP/UNTIL/WHILE/REPEAT structures alter the program execution sequence based upon a Flag. These structures use the following format:
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
|
|
|
|
|
|
|
|
... zero or more PL/B instructions | |
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
flag
Required. A valid check for a Flag.
expression
Required. A valid check for an Expression.
Flags Affected: Function Key
Note the following:
A {flag}, NOT {flag}, {expression} or NOT {expression} test is required.
LOOP is a starting point for a group of instructions that are repeated. REPEAT returns the program execution to the first instruction after LOOP if the test results are positive. The program instructions between LOOP and REPEAT are processed sequentially in a repetitive fashion. When the WHILE structure generates a negative test result or the UNTIL generates a positive test result, program control is transferred to the first instruction following the REPEAT structure.
If a FILEPI instruction is active, the FILEPI count is not decremented by this instruction.
Each LOOP must have a corresponding REPEAT but may have an unlimited number of UNTIL and WHILE structures (within program code size limitations). Any mixture of UNTIL or WHILE instructions are allowed within a LOOP/REPEAT structure.
UNTIL or WHILE may be used as a test compliment to a REPEAT as one structure.
LOOP/REPEAT or IF/ELSE structures may be nested within each other as long as they do not cross the boundary of the structures they are nested within.
Program Control Instructions such as GOTO, CALL, BRANCH, etc., may be placed within a LOOP/REPEAT structure. However, they alter the structure's flow.
LOOP/REPEAT structures may be nested thirty-two (32) levels deep.
The execution of a LOOP/REPEAT structure may be restarted at any point in the structure, even inside of nested IF/ENDIF structures by using the CONTINUE instruction.
The execution of a LOOP/REPEAT structure may be terminated at any point in the structure, even inside of nested IF/ENDIF structures by using the BREAK instruction.
The UNTIL and WHILE statements cannot be nested in an IF statement.
See Also: Example Code, BREAK/CONTINUE, Program Control Instructions
![]() |