For Statement - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

100BBasic instructions
7.8 Program control
END_CASE
7.8.4

FOR statement

Table 7- 97
Elements of the FOR statement
SCL
FOR "control_variable" := "begin" TO "end"
[BY "increment"] DO
statement;
;
END_FOR;
Table 7- 98
Parameters
Parameter
"control_variable"
"begin"
"end"
"increment"
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 215). The EXIT statement executes the statement immediately following the
END_FOR statement.
Use the CONTINUE statement (Page 214) 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.
212
Description
Required. An integer (Int or DInt) that serves as a loop counter
Required. Simple expression that specifies the initial value of the control variables
Required. Simple expression that determines the final value of the control variables
Optional. Amount by which a "control variable" is changed after each loop. The "increment"
has the same data type as "control variable". If the "increment" value is not specified, then
the value of the run tags will be increased by 1 after each loop. You cannot change
"increment" during the execution of the FOR statement.
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 condition is satisfied, the sequence of
statements is executed, otherwise the loop and with it the sequence of statements is
skipped.
assumed to be +1.
Description
A FOR statement is used to repeat a sequence of
statements as long as a control variable is within
the specified range of values. The definition of a
loop with FOR includes the specification of an
initial and an end value. Both values must be the
same type as the control variable.
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-1200

Table of Contents