An expression is a construction which after its evaluation returns a value. This value is used in instructions.
Expressions are composed of operators, operands, and/or assignments. An operand can be a constant, a variable, a function call, or another expression.
Examples
|
(* Constant *) |
|
(* Variable *) |
|
(* Function call*) |
|
(* Expression *) |
|
(* Expression *) |
|
(* Assignment, see below *) |
The evaluation of an expression is performed by processing the operators according to certain rules. The operator with the highest order of operation is processed first, then the operator with the next operating level, and so on, until all operators have been processed.
Below you find a table of the ST operators in the order of their ordinal operating level:
Operation |
Symbol |
Operating Level |
---|---|---|
placed in parentheses |
(expression) |
highest order |
function call |
function name (parameter list) |
.............. |
exponentiation |
EXPT |
............. |
negate |
– |
............ |
building of complements |
NOT |
........... |
multiply |
* |
.......... |
divide |
/ |
......... |
modulo |
MOD |
........ |
add |
+ |
....... |
subtract |
– |
...... |
compare V |
<,>,<=,>= |
..... |
equal to |
= |
.... |
not equal to |
<> |
... |
boolean AND |
AND |
.. |
boolean XOR |
XOR |
. |
boolean OR |
OR |
lowest order |
As an extension to the IEC 61131-3 standard (ExST), assignments can be used as an expression.
Examples:
|
(* |
|
(* correct assignments, |
|
(* a message will be displayed due to type mismatch |
|
(*Expression used inside of IF condition statement: First |