Working through the Ignition design challenge and struggling with the following. Attempting to change tag values from a popup window. I have a text box in the popup where you enter a value. Then I have a button that, upon clicking, writes the value you entered to the "brewType" tag. The code I have below is script from the button event configuration, and it worked just fine until I made the tag path dynamic. For example, when path = "[default]Brewing Tags/Station 2/brewType", it works just fine for changing station 2's brew type but only that station. Note, I have also tried making a custom property, binding it to the brewStation parameter, and using that instead of the parameter, that hasn't worked either. I have tested whether or not the parameter and the custom property are correctly receiving the numbers, and they are. But whenever I attempted this as shown below, nothing happens. Any advice?
How are you determining that nothing happens? Have you tried inspecting the output from writeBlocking? Have you confirmed that the tag path being created is the one you are looking for?
based on this, you are missing a space in your string.
When I just use a number value for the station as mentioned, like "Station 2", the brewType tag value will update. When I first established the Station 2 brew type tag, the value was 0. Then, when I enter something simple into my text box like 7 and press my button, the brewType tag value for Station 2 will update to 7. However, when I am using the dynamic path that I listed above, nothing happens. It remains 0.
I tried adding the space to my string and I still get no changes.
You need to pass lists to system.tag.writeBlocking function for your tag paths and values.
Try system.tag.writeBlocking([path], [newval]) instead. system.tag.writeBlocking | Ignition User Manual
I was basing my notation on the Expression Dynamic Tag Path example under the Using Relative Tag Paths section of this page: Tag Paths | Ignition User Manual
Was I misunderstanding this example?
But also, that's a terrible example to put in the user manual. It is a Vision UI usage of tag(), which simply should never be done. Perhaps @kvane can alter that to be something typical in an expression tag instead of a UI binding.
My tag still isn't updating, but I added a custom parameter to my view called "dynamic" and set that equal to path, as you can see above. I included a label in my popup window who's text is bound to property I created called "dynamic", so I can see the tag path being created. So this time when I pressed my button, the label updated to "[default]Brewing Tags/Station value/brewType".
I know the challenge and this is correct, you do not need to use scripts for this portion. If you are doing so for testing that is fine, but you should use the indirect tag binding.
Maybe I am misunderstanding what you mean by monitor, but I am looking at the tag browser in the ignition designer, so that I can see the tag's current value. I also have a label in the popup with an indirect tag binding to the tag value like this [default]Brewing Tags/Station {brewStation}/brewType. When I am not trying to use a dynamic path, both the value in the tag browser and the label I mention here update correctly with the value I want, but neither do when it is a dynamic path.
I don't think I understand what you mean, but what you are saying sounds easier than what I am doing so I would like to understand. The popup view section of the challenge says that the popup view should provide a way for users to view and change the name of the current coffee being brewed at the station. I took that to mean that there should be a text box in the popup window where you can enter your desired name and a button that will update the brewType tag value with that desired name. Ignition university made me think that the easiest way to do that would be to configure an event on the onActionPerformed option for the button component, which gets the value entered by in the textbox and sends it to the tag. Does that part sound correct?
Did you define a connection for {brewStation}? It isn't valid by itself. As soon as you introduce a curly-brace delimited name or number, the binding UI should place that reference into the row of substitutions below that string. In the row for that substitution, you need to connect to the actual parameter or tag you want there.
(It is typical to use just {1} in the indirect binding string to avoidminimize confusion.)
Yes, I think I understand what you mean, this is the indirect binding I made. I used the same names rather than a {1} because the values being put into the tag path would be 1 through 20 so I thought {1} would be confusing at first glance.