For Statement - Siemens S7-1200 System Manual

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

Advertisement

Basic instructions
7.8 Program control operations
CASE statements can be nested. Each nested case statement must have an associated
END_CASE statement.
CASE "var1" OF
ELSE
END_CASE;
7.8.9.4

FOR statement

Table 7- 118 Elements of the FOR statement
SCL
FOR "control_variable" := "begin" TO "end"
[BY "increment"] DO
statement;
;
END_FOR;
Table 7- 119 Parameters
Parameter
"control_variable"
"begin"
"end"
"increment"
270
1 : #var2 := 'A';
2 : #var2 := 'B';
CASE "var3" OF
65..90: #var2 := 'UpperCase';
97..122: #var2 := 'LowerCase';
ELSE
#var2:= 'SpecialCharacter';
END_CASE;
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.
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.
You can nest FOR loops. The END_FOR
statement refers to the last executed FOR
instruction.
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG

Advertisement

Table of Contents
loading

Table of Contents