Basic instructions
7.8 Program control operations
S7-1200 Programmable controller
272 System Manual, 03/2014, A5E02486680-AG
The WHILE statement executes according to the following rules:
● Prior to each iteration of the loop body, the execution condition is evaluated.
● The loop body following DO iterates as long as the execution condition has the value
TRUE.
● Once the value FALSE occurs, the loop is skipped and the statement following the loop is
executed.
To end the loop regardless of the state of the "condition" expression, use the EXIT statement
(Page 273). The EXIT statement executes the statement immediately following the
END_WHILE statement
Use the CONTINUE statement to skip the subsequent statements of a WHILE loop and to
continue the loop with the examination of whether the condition is met for termination.
Table 7- 122 REPEAT instruction
Statement;
;
UNTIL "condition"
The REPEAT statement executes a group of statements until a given condition is
TRUE.
You can nest REPEAT loops. The END_REPEAT statement always refers to the last
executed Repeat instruction.
Table 7- 123 Parameters
Optional. One or more statements that are executed until the condition is TRUE.
"condition" Required. One or more expressions of the two following ways: A numeric expression or string
expression that evaluates to TRUE or FALSE. A "null" condition is interpreted as FALSE.
Note
Before evaluating the state of "condition", the REPEAT statement executes the statements
during the first iteration of the lo
op (even if "condition" is FALSE). To review the state of
"condition" before executing the statements, use the
WHILE statement (Page 271).
To end the loop regardless of the state of the "condition" expression, use the EXIT statement
(Page 273). The EXIT statement executes the statement immediately following the
END_REPEAT statement
Use the CONTINUE statement (Page 273) to skip the subsequent statements of a REPEAT
loop and to continue the loop with the examination of whether the condition is met for
termination.