-

Using Expressions for Object Animation

Expressions can be used to perform logical or mathematical operations on HMI tag values, variables, etc. They are a combination of operands (variables, HMI tags, constants, etc.) that are linked by suitable operators (+ * -). Expressions allow you to compare data with other values or combine them with other values. You can use expressions, for example, to define the condition for animating an object based on the expression result.

An expression always returns a single value after its evaluation. For example, the expression MyVar > 10 evaluates to TRUE, if the value of the variable MyVar is greater 10.

Expressions are allowed anywhere in PLCnext Engineer where a variable or HMI tag is expected. They can be built from:

Operands are logically combined using operators. In an expression, the operator with the highest priority is executed first, followed by the operator with the next lower priority (see below for the evaluation order).

Expressions with reference to multi-element variable

Expressions can contain references to multi-element variables (arrays and structures). The data elements of an array are accessed by specifying the element number in square brackets following the variable name of the array. The data elements of a structure element are accessed by specifying the variable name of the structure followed by a dot and the name of the structure component in square brackets.

Examples

Partial access of specific parts of ANY_BIT variables used in expressions

The access to specific parts of an ANY_BIT variable (BYTE, WORD, DWORD, LWORD) included in expressions is supported. The partial access to a variable is programmed by adding a dot (.) to the variable name followed by the optional '%' sign, the size prefix and an integer number (from 0 to max) for the address within the variable.

Example: MyByteVar.%X3

Further Info
For further details, see the topic "Partial Access to ANY_BIT Variables".

Operators

The following operators can be used in an expression:

Arithmetic operators

Relational operators

Logical operators

Evaluation order of operators

Using string functions in expressions

PLCnext Engineer provides a number of built in functions that you can use in expressions for examining string values. String functions perform an operation on the string values passed as parameters and return a string or numeric value.
For each of the provided string functions, the strings passed as parameters may be an expression of the type STRING, a user-defined string type, or a parameter of type ANY_STRING. Numeric values passed as parameters may be any expression of the type ANY_NUM.

All string functions can be nested within each other. This means, the functions can be used as parameters of other functions. For example:

      substring(TestString, indexOf(TestString,'_'))

returns the substring in TestString beginning at the position of the fist occurrence of the character "_" within TestString. If, for example, TestString contains the value 'abcd_12345', the substring '12345' is returned.

Application example

The following string functions are available:

concat()

indexOf()

lastIndexOf()

left()

right()

substr()

substring()