Version:

LESSON

Tag Binding - Expression

Description

Learn how to configure a Tag binding using an expression to dictate the Tag path.

Video recorded using: Ignition 8.0

Transcript

(open in window)

[00:00] When working with complicated tag structures, it could prove useful to forego an Indirect Tag Binding and build an entire tag binding path from scratch. For this use case, we've provided a Tag Binding type called Expression. Not to be confused with an Expression Binding, this Tag Binding type allows us to use Ignition's expression language to dynamically specify an entire tag path. Here I have two tags I'd like to work with, one called Tag A, which is simply in the root directory of our tag provider. And I have another tag called Tag B, which is in this folder called Other Tags. I would like to configure a tag binding that will take in as a parameter either Tag A or Tag B, and appropriately direct to the correct tag. So to demonstrate, I've configured a couple buttons here. One is Open with Tag A. If I go to Events, I can see that it's opening our pop-up View that I'd like to use. It's passing in a parameter called tagToShow with a value of Tag A. I have another button, which is functionally the same except that it passes in a value of Tag B. So my pop-up view has this parameter configured called tagToShow. It has a label at the top that's simply showing the value that's passed in. And what I'd like to do is I'd like to take this text field component and bind its text to the tag that I'm passing in. So to do this, I'll configure a binding on the text property of the component. It will be a Tag Binding. And I'll use a binding type of Expression. Note that I could use an Indirect Tag Binding for this purpose, but it wouldn't get me very far, as the tag paths for our two tags are totally different. So the expression I'd like to use here is pretty simple. I'm just going to expand this so we have more room to work with. I already have the expression configured I'd like to use so I'm just going to paste it in. We can see it's a very simple expression. If the parameter that I pass in is equal to Tag A, bind it to the path Tag A. Otherwise, bind it to the path Other Tags/Tag B. Since I'm using a Text Field, I'd also like to make this bidirectional so the user can change the value on the tag. That's all it takes to configure. I'm going to click OK. And then to see this in action, I'm going to save our project. Then I'm going to launch a session. So I'm going to come to Tools, Launch Perspective, and Launch Session. And as we can see, when we open with Tag A, it shows Tag A and the text for Tag A. And when I open with Tag B, it shows Tag B and the text for Tag B. And if I'd like, I can change the text here to say whatever I'd like. And as we can see, it's been updated on our tag.

You are editing this transcript.

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