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
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.
Conditions
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
#CHAR1 < 'S'
(#Alpha <> 12) AND NOT #Beta
5 + #Alpha
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.
Addressing
As with LAD and FBD, SCL allows you to use either tags (symbolic addressing) or absolute
addresses in your user program. SCL also allows you to use a variable as an array index.
Absolute addressing
I[byteindex.bitindex]
MB[byteindex]
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
sum := sum + value(x);
Relational expression
Comparison and logical expression
Arithmetic expression
In these examples, the tags "byteindex" and
"bitindex" are tags that store the value (Int) used to
determine the address to be accessed. Your user
program can change the value of these tags, which
then changes the address in the statement or
expression.
99BProgramming concepts
6.5 Programming language
149