Expressions and Parentheses

Structured Text (ST) expressions combine ST operators and variable or constant operands. For each single expression (combining operands with one ST operator), the type of the operands must be the same. This single expression has the same data type as its operands, and can be used in a more complex expression. For example:
Single expression
(boo_var1 AND boo_var2)
has BOOL type
not (boo_var1)
has BOOL type
(sin (3.14) + 0.72)
has REAL type
(t#1s23 + 1.78)
is an invalid expression
Parentheses are used to isolate sub parts of an expression and to explicitly order the priority of operations. When no parentheses are given for a complex expression, the operation sequence is implicitly given by the default priority between ST operators. For example:
Parentheses priority
2 + 3 * 6
equals 2+18=20
because multiplication operator has a higher priority
(2 + 3) * 6
equals 5*6=30
priority is given by parenthesis
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal