Description

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.

Video recorded using: Ignition 7.7

Transcript

(open in window)

[00:00] An expression binding is one of the most powerful kinds of property bindings that we have in Ignition. It uses a simple expression language to calculate a value. This expression can involve lots of dynamic data, such as other properties on the screen, tag values, results of scripts, queries, and more. Expressions can be used for many different purposes. Anytime information needs to be massaged, manipulated, extracted, combined, split, you think expressions. So here I have a couple of LED displays on my window, and I want to display a couple different values using the expressions language. The first one, I want to display the addition of ramp zero, and ramp one. So I want to add these two tags together. I can't do that with the tag binding, I have to use an expression. So I go down to the value property here I'm going to bind this to an expression and I can type in the expression in this box here. On the right hand side I can bring in any property value from the screen. I can also bring any tag value in. And I have various operators, such as mathematical, logical, and bitwise operators. And I have various functions I can bring in such as math functions, logic functions, and date and time functions. So this expressions going to be turned into a single result. That I'm going to display on this component. So if I want to add ramp zero and ramp one together I'm first going to go and bring in those tags into the expression. I'm going to use the tag button on the right hand side to first bring in ramp zero. Go ahead press okay, you'll see its going to put a curly brace, ramp four slash ramp zero, which is a reference to that tag. Then I'm going to go plus, and then go and bring in ramp one. So, I'm bringing ramp one. Now that I have the expression done, as soon as I press okay, I'll see the value of that expression here on the LED display. Now not only can we use tag values in expressions, of course we can use values from the screen as well. So here I have a numeric text field, that if I go in and type maybe a value of say 100, maybe I want to take the value, the addition of ramp zero and ramp one and then subtract 100 from it. So I'm going to back into the binding on the LED display. Where I have ramp zero plus ramp one, and now I'm going to subtract the value of that numeric text field. So simply going to go minus, and use the link now because its a property on the window. So click on the link, go on find in my window, numeric text field and bring its value integer. So I can not only bring in tags I can bring in properties from the screen, soon as I press okay, now I'll see the calculation of that. On the second LED display, lets do another example of expression. But this time lets utilize one of the functions that we have. So here I have a tag called rival integer one and right now the value is negative five. Lets say I want to show the absolute value of that, I want to just show 5, on the LED display here. So I can actually bind the value of this one, again to an expression, and this time I'm going to use a function. In the function language we have various mathematical functions, one of them is absolute value. So I can simply click on absolute, it's going to put abs and then a parentheses, the parentheses notes that we're going to call a function here. Then inside the parentheses I'm going to bring in the value that I wanted the absolute value on. So I'm going to go and use the tag button on the right hand side, to go and select my writable integer one, go ahead and press okay and bring that in, and then I'm going to end parentheses to finish out that function. As you can see if you put your cursor at the end, you can see that it matches up with the beginning one. Soon as I press okay I will then see now the absolute value of whatever I type in here, in that writeable integer one tag. So the expression language is very powerful and there's lots of different ways that we can use it.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.

close

Share this video