While-Do Statement - Siemens S7-1200 System Manual

Hide thumbs Also See for S7-1200:
Table of Contents

Advertisement

The FOR statement executes as follows:
● At the start of the loop, the control variable is set to the initial value (initial assignment)
● Following each run through of the loop, the condition is checked (final value reached) to
Rules for formulating FOR statements:
● The control variable may only be of the data type Int or DInt.
● You can omit the statement BY [increment]. If no increment is specified, it is automatically
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_FOR statement.
Use the CONTINUE statement (Page 273) to skip the subsequent statements of a FOR loop
and to continue the loop with the examination of whether the condition is met for termination.
7.8.9.5

WHILE-DO statement

Table 7- 120 WHILE statement
SCL
WHILE "condition" DO
Statement;
Statement;
...;
END_WHILE;
Table 7- 121 Parameters
Parameter
"condition"
Statement
Note
The WHILE statement evaluates the state of "condition" before executing any of the
statements. To execute the statements at least one time regardless of the state of
"condition", use the REPEAT statement (Page 272).
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
and each time the loop iterates, it is incremented by the specified increment (positive
increment) or decremented (negative increment) until the final value is reached.
establish whether or not it is satisfied. If the end condition is not satisfied, the sequence of
statements is executed again, otherwise the loop terminates and execution continues
with the statement immediately following the loop.
assumed to be +1.
Description
The WHILE statement performs a series of statements until a given condition is
TRUE.
You can nest WHILE loops. The END_WHILE statement refers to the last executed
WHILE instruction.
Description
Required. A logical expression that evaluates to TRUE or FALSE. (A "null" condition is
interpreted as FALSE.)
Optional. One or more statements that are executed until the condition evaluates to TRUE.
Basic instructions
7.8 Program control operations
271

Advertisement

Table of Contents
loading

Table of Contents