EasyManua.ls Logo

Siemens SIMATIC S7-1200 - Page 204

Siemens SIMATIC S7-1200
1614 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...
Programming concepts
7.5 Programming language
S7-1200 Programmable controller
204 System Manual, V4.2, 09/2016, A5E02486680-AK
Control statements
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.
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'
Relational expression
(#Alpha <> 12) AND NOT #Beta
Comparison and logical expression
5 + #Alpha
Arithmetic 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.

Table of Contents

Other manuals for Siemens SIMATIC S7-1200

Related product manuals