Skip to main content

ST Expressions

An expression is a construct that returns a value following its evaluation.

Expressions consist of operators and operands. In Extended Structured Text (ExST), you can also use assignments as expressions.

An operand can be a constant, variable, function call, or another expression.

Special ST expressions are also:

  • Access to

    • Elements of array variables

    • Components of a structure variable

    • Variables of a function block instance or a program

  • Method call

Example 62. Examples

2014

Constant, literal

ivar

Variable

fct(a,b)

Function call

(x*y)/z

Expression

real_var2 := int.var;

In ExST: Assignment



Evaluation of expressions

An expression is evaluated by processing the operators according to specific binding rules. CODESYS first processes the operator with the strongest binding. Operators with the same binding strength are processed from left to right.

Operation

Symbol

Binding strength

Bracketing

( <expression> )

Strongest binding

Function call

<function name> ( <parameter list> )

All operators with syntax: <operator> ()

Exponentiate

EXPT

Negate

Complementation

-

NOT

Multiplication

Division

Modulo

*

/

MOD

Addition

Subtraction

+

-

Compare

<,>,<=,>=

Equality

Inequality

=

<>

Boolean AND

AND, AND_THEN

Boolean XOR

Boolean OR

XOR

OR, OR_ELSE

Weakest binding