REPEAT¶
The REPEAT statement executes a statement list and then evaluates a
boolean condition to determine whether to repeat.
IEC 61131-3 |
Section 3.3.2.4 |
Support |
Supported |
Syntax¶
REPEAT
statement_list
UNTIL expression
END_REPEAT ;
The UNTIL expression must be of type BOOL. A condition of any other
type, such as an integer or a WORD, is reported as
P4072.
Description¶
The REPEAT loop executes the statement list at least once. After each
iteration, the boolean expression is evaluated. If the expression is TRUE,
the loop terminates. If it is FALSE, the statement list executes again.
This is the opposite of a WHILE loop: WHILE continues while the
condition is true, whereas REPEAT continues until the condition becomes
true.
Example¶
PROGRAM main
VAR
count : INT := 0;
END_VAR
REPEAT
count := count + 1;
UNTIL count >= 10
END_REPEAT;
END_PROGRAM