Hide thumbs Also See for S7-1200:
Table of Contents
Programming concepts
6.5 Programming language
The following examples show different expressions for different uses.
"C" := #A+#B;
"Data_block_1".Tag := #A;
IF #A > #B THEN "C" := #A;
"C" := SQRT (SQR (#A) + SQR (#B));
Arithmetic operators can process various numeric data types. The data type of the result is
determined by the data type of the most-significant operands. For example, a multiplication
operation that uses an INT operand and a REAL operand yields a REAL value for the result.
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
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: ;
The STEP 7 online help provides a complete SCL programming language reference.
184
sum := sum + value(x);
Assigns the sum of two local variables to a tag
Assignment to a data block tag
Condition for the IF-THEN statement
Parameters for the SQRT instruction
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
Table of Contents
loading

Table of Contents