Appendix C
Structured Text Programming
Statement 1
Statement 2
Statement 3
Statement 4
...
BOOL expression
False
While the bool_expression is false, the controller
executes only the statements within the REPEAT...UNTIL
loop.
Arithmetic Status Flags:
Fault Conditions:
If you want this
The REPEAT...UNTIL loop executes the statements in the construct
and then determines if the conditions are true before executing the
statements again.
This differs from the WHILE...DO loop because the WHILE...DO The
WHILE...DO loop evaluates its conditions first. If the conditions are
true, the controller then executes the statements within the loop. The
statements in a REPEAT...UNTIL loop are always executed at least
once. The statements in a WHILE...DO loop might never be executed.
694
The following diagrams show how a REPEAT...UNTIL loop executes and how
an EXIT statement leaves the loop early.
True
Rest Of The Routine
Not affected
A major fault will occur if
The construct loops too long
Example 1:
Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Statement 1
Statement 2
Statement 3
statement 4
...
Exit ?
No
BOOL expression
False
To stop the loop before the conditions are false, use an EXIT
statement.
Fault type
6
Enter this structured text
pos := -1;
REPEAT
pos := pos + 2;
UNTIL ((pos = 101) OR (structarray[pos].value = targetvalue))
end_repeat;
Yes
True
Rest Of The Routine
Fault code
1