Programming concepts
7.5 Programming language
S7-1200 Programmable controller
204 System Manual, V4.2, 09/2016, A5E02486680-AK
A control statement is a specialized type of SCL expression that performs the following
tasks:
● Program branching
● Repeating sections of the SCL program code
● Jumping to other parts of the SCL program
● Conditional execution
The SCL control statements include IF-THEN, CASE-OF, FOR-TO-DO, WHILE-DO,
REPEAT-UNTIL, CONTINUE, GOTO, and RETURN.
A single statement typically occupies one line of code. You can enter multiple statements on
one line, or you can break a statement into several lines of code to make the code easier to
read. Separators (such as tabs, line breaks and extra spaces) are ignored during the syntax
check. An END statement terminates the control statement.
The following examples show a FOR-TO-DO control statement. (Both forms of coding are
syntactically valid.)
FOR x := 0 TO max DO sum := sum + value(x); END_FOR;
FOR x := 0 TO max DO
sum := sum + value(x);
END_FOR;
A control statement can also be provided with a label. A label is set off by a colon at the
beginning of the statement:
Label: <Statement>;
The STEP 7 online help provides a complete SCL programming language reference.
A condition is a comparison expression or a logical expression whose result is of type BOOL
(with the value of either TRUE or FALSE). The following example shows conditions of
various types:
#Temperature > 50
#Counter <= 100
(#Alpha <> 12) AND NOT #Beta
Comparison and logical expression
A condition can use arithmetic expressions:
● The condition of the expression is TRUE if the result is any value other than zero.
● The condition of the expression is FALSE if the result equals zero.