Programming concepts
7.5 Programming language
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
203
The result of an expression can be used either for assigning a value to a tag used by your
program, as a condition to be used by a control statement, or as parameters for another SCL
instruction or for calling a code block.
Table 7- 2 Operators in SCL
Math Power ** 2
Sign (unary minus) - 3
Comparison
Bit logic
Exclusive OR logic operation
As a high-level programming language, SCL uses standard statements for basic tasks:
● Assignment statement: :=
● Mathematical functions: +, -, *, and /
● Addressing of global variables (tags): "<tag name>" (Tag name or data block name
enclosed in double quotes)
● Addressing of local variables: #<variable name> (Variable name preceded by "#" symbol)
The following examples show different expressions for different uses:
Assigns the sum of two local variables to a tag
"Data_block_1".Tag := #A;
Assignment to a data block tag
IF #A > #B THEN "C" := #A;
Condition for the IF-THEN statement
"C" := SQRT (SQR (#A) + SQR (#B));
Parameters for the SQRT instruction
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.