Skip to main content
Version: 8.1

Expression Binding in Vision

Inductive University

Expression Binding

Watch the video

Binding Properties to the Outcome of an Expression​

An expression binding is one of the most powerful kinds of property bindings. It uses a simple expression language to calculate a value. This expression can involve lots of dynamic data, such as other properties, Tag values, results of Python scripts, queries, and so on. Any time information needs to be massaged, manipulated, extracted, combined, split, and so on, expressions can get the job done.

Event Based and Polling​

Expression bindings fall into the unique category of having the possibility of using both Events and Polling to update. How an expression updates depends on what is being done in the expression. Expression bindings will always update immediately when the window they are in is opened. When they update again depends on if they are driven by events or polling. Typically, expressions are driven by events. If the expression was adding multiple values together, then when one of those values changed the expression would update, regardless of whether those values came from other properties or Tags. However, the expression function has some unique functions that can update at a set rate such as the now() function. When these functions are used within the expression, the expression binding will update based on the specified polling rate.

Using Expression Bindings​

The expression language has lots of tools available that help calculate a specific value such as built-in expression functions, multiple operators, and the ability to reference Tags. While all of these can be manually typed into the expression, the expression binding window makes it easy to reference these options.

Helper Icons​

To the right of the expression binding window, there are four icons that can be used to reference specific objects or functions easily.

  • Properties - Places a property reference into the expression at the cursor, pulling in that property's value into the expression at the time of evaluation.
  • Tags - Places a Tag reference into the expression at the cursor, pulling in that Tag's value into the expression at the time of evaluation.
  • Operators - Places the operator into the expression at the cursor. Mostly used as a reference to what operators are available for use.
  • Functions - Places the function into the expression at the cursor. Can be used as a reference for what functions are available, as well as the parameters the function is expecting.

Expression Binding Examples​

Example 1​

You have a button that starts a batch, but you only want to let it be pressed after the operator entered a scale weight. An expression binding can be set up on the enabled property of the button:

{Root Container.EntryArea.WeightBox.doubleValue} > 0.0

Example 2​

You want to display a process's current state, translating a code from the PLC to a human-readable string. The examples below will yield the same results, but in different ways.

This first example uses nested "if" statements to produce the string. Notice that the false return for the first "if" statement is another "if" function, and the same with the second "if" function. Since the "if" function can only do simple if/than/else logic, this method allows us to do an if/than/else if/else.

if ({CurrentProcessState} = 0, "Not Running",
if ({CurrentProcessState} = 1, "Warmup phase - please wait",
if ({CurrentProcessState} = 2, "Running", "UNKNOWN STATE")))

This example will yield the same result as the previous example, but works differently. Instead of using multiple functions, this example uses a single switch function to decide which string to use.

switch ({CurrentProcessState},
0,1,2,
"Not Running",
"Warmup phase - please wait",
"Running",
"UNKNOWN STATE")

For more examples, see Expression Overview and Syntax.