Expressions

Expressions consist of operands linked by operators based on their precedence.

Example

Description

A+B

The sum of operands A and B is called expression.

When their precedence is the same, processing proceeds from left to right.

With the values A:=1.0; B:=2.0; C:=3.0; and D:=4.0; for

X:=A+B-C*SQRT(D);

the result is -3.

By inserting parentheses, the processing order can be changed, e.g. for

X:=A+(B-C)*SQRT(D);

the result is -1.

Boolean expressions are always fully processed:

IF a<100 AND UserFun1(a) THEN
    a:=a+1;
END_IF;

In this case, UserFun1 is also processed if a>=100.

When you wish to avoid processing UserFun1 for whatever reason, e.g. it’s too time-consuming, or when a>=100 an operation error occurs, or because the memory area will be overwritten, you can write, for example:

IF a<100 THEN
    IF UserFun1(a) THEN
        a:=a+1;
    END_IF;
END_IF;

Expressions can also indicate elements of an array:

X:=Array1[i+2];
Related topics:

Operands

Operators of ST editor

Modified on: 2019-01-26Feedback on this pagePanasonic hotline