Tag Binding with Expression

Is it possible to link the binding to a tag with an expression like the below:

I can't figure this out. I am actually able to link with expression when expression is selected on the left, but not able to link with expression when tag is selected on the left.

Here's the pertininent info in the manual. That said, what are you really trying to do?

1 Like

I'm trying to setup dynamic binding therefore I need an expression.

Have you tried indirect binding?

1 Like

I suspect this is really what you need to use

Is the tag path you are trying to bind to wildly changing, or is it another tag in the same folder or a different sibling folder with the same structure? Which part of the tag path will be changing?

If possible try to provide more information on how your system is set up and what you are trying to achieve. Something along the lines of:
I have a standard folder structure of Foo which contains tags bar and est. I have 4 machines with folders that follow this structure and I want to bind the value of est to a label component based on the folder/machine I have selected.

1 Like

I tried indirect binding and of course it works for me, but this is not what I want. As I said before, I want to use the expression and since the option is available there, it should be possible right???. There will be some logic in my expression which I would not be able to do with the indirect binding.

In that expression you are passing the value from the tag you've written there. You can tell because its surrounded with {}. I'm assuming ignition wants to see a string returned from the expression which it will then interpret as a tag path to bind indirectly. Try replacing the {} with " ".

I am not sure Ryan, therefore I wanted to know what is the syntax. I was able to do an expression which reads from the tag before, but that was using the actual expression Binding Type. In this case I want it to work bidirectional, therefore I wanted to use the Tag binding type.

Right, so this expression works as you can see.

The same expression does not work for the Tag Binding type. So what is the syntax I'm asking basically.

Correct, because that binding is returning the value of the tag at that path (that's what the tag function does). For the tag type binding, it wants to see a tag path, not a tag value. Your expression binding for the tag binding type should just be

"[default]ReadPoints/WTN_M7/DataWrite/Vsl_NameWrite"

Leave off the quotes for a plain tag binding. Include the quotes for an expression tag binding. Leave off the quotes, and put in a curly brace placeholder, to use indirect binding.

1 Like

Definitely read the manual/check the videos as well.

Quick snippet from the manual for the type of binding you are attempting:
"The tag path in the Expression is expected to be a string. Note that is different and not to be confused with an Expression Binding."

Yeah, thanks pturmel, Actually just figured it out:

1 Like

Found this in manual actully pointed me to the right direction:

I was using the tag button on the right of the screen to create the connection to my tag and it did not work. I think that maybe it's something that could be fixed in the future versions of Ignition as I believe that using this in this context should actually resolve the path to the tag and paste it in the quotation marks in the expression window.

That would be used to identify a tag that will supply a string containing the path to another tag, or to supply conditions for the expression to yield a string.

Summary:

  • Direct tag binding: Put the complete path to the tag, without quotes, into the top field.

  • Indirect tag binding: Put part of the path to the tag, without quotes, into the top field, plus a curly-brace placeholder for the part of the tag name you wish to be dynamic. In the parameter section below, indicate where you want to get that part.

  • Expression tag binding: Put a computation that yields a string that will be the complete name of the the tag.

Use in that order, for best efficiency. Don't use expression tag bindings where you are just injecting something else into the name. Use indirect for that.

1 Like

I've seen in some other editors (In Ignition) that selecting the tag from the right pane actually inserts the tag full path string in quotation.

In this editor using the button inserts the full path string in the Curly Brackets. The curly brackets are generally used for referencing the objects in Ignition from what I've seen so it does not make sense to me.

In an expression, curly brackets are used to delineate a path (tag path, property path, etc...), that the expression should try to use the value of. Behind the scenes the paths are parsed to determine if they are a path to a property or a tag, and either a BoundTagExpression or BoundPropertyExpression is created. Effectively the component is "listening" for a change in those expressions.

A path in quotations is just a string.

1 Like