EasyManua.ls Logo

Siemens S7-1200 - WHILE-DO Statement

Siemens S7-1200
1028 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Basic instructions
7.8 Program control operations
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
271
The FOR statement executes as follows:
At the start of the loop, the control variable is set to the initial value (initial assignment)
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.
Following each run through of the loop, the condition is checked (final value reached) to
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.
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
assumed to be +1.
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
Description
WHILE "condition" DO
Statement;
Statement;
...;
END_WHILE;
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.
Table 7- 121 Parameters
Parameter
Description
"condition" Required. A logical expression that evaluates to TRUE or FALSE. (A "null" condition is
interpreted as FALSE.)
Statement
Optional. One or more statements that are executed until the condition evaluates to TRUE.
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).

Table of Contents

Other manuals for Siemens S7-1200

Related product manuals