Expressions overview
An expression is a tag name or an equation that returns a numeric value, true or false value, or text string. Use expressions to make the data you gather from devices more meaningful by comparing it to other values, combining it with other values, or creating cause-and-effect relationships between values.
You can also use expressions to write or increment values in the controller by including them in events.
Most expressions consist of one or more tag references combined with numbers, mathematical operators, or built-in functions. However, a tag is not required in an expression.
To create an expression, you can:
- Type it directly into the expression/binding box.
- Open theExpression Editorand create the expression in the editor.
View Designer
checks the expression syntax as you create the expression. A redView Designer
also verifies the syntax for all expressions in a project before it is downloaded to the HMI device. In addition, it verifies that tag references exist in the controller projects. It also verifies that the property of a graphic element referenced in an expression exists in the screen where it exists. If there are invalid expressions, the download process stops, and the invalid expressions appear in the Errors
window. Verify expressions any time during the project development process by using the PROJECT > Verify Project
command.- Numeric literals
- String literals
- Tags
- Numeric operators
- Functions
- String functions
- Conditional statements
- Relational operators
- Logical operators
- Bitwise operators
- Properties of graphic elements
You can add white space to expressions in the form of spaces and new lines. Use white space to format expressions so that they are easier to read. For example, add new lines to separate conditions in a complex expression.
Use expressions in:
- Events (Value commands only)
- Animations (State Tables and Color Tables)
- Properties (Any bindable property)IMPORTANT:
- Using LINT tags in expressions, write commands, or increment commands is not recommended. This is because the values may lose resolution as a result of performing the expression calculations.
- Using strings in numeric operations is not recommended. The exception is the + operator, which is used for string concatenation.
The Value property of a Numeric Display graphic element evaluates as a string value in an expression. For example, if the value of NumericDisplay_001.value is 25, and the value of NumericDisplay_003.value is 30, then NumericDisplay_001.value + NumericDisplay_003.value will return 2530, not 55.- Using an alias property in an expression is not supported.
- The HMI device updates data from controllers at a fixed rate of 100, 250, or 500 milliseconds. This update is asynchronous to any scan in a controller.
Provide Feedback