01-27-2019 02:12 PM
Hi all,
I'm struggling several days with a problem: how can I make the binding between a local variable and a control dynamic?
What does I mean:
-I have a 2D matrix of strings. The first column are names of variables in my vi. The second column are values that these variables should have (can be strings, can be numerical values, can be booleans). The order of the variable names in the first column is variable, not all variables in my vi are present and at the next execution the list can be changed (other variables in column 1 and/or other order).
-is there an elegant way to update the variables mentioned in column 1 with the values present in column 2?
I should like to avoid to add a search engine that checks every single variable in my vi's presence in that list, linking the result of that search with a local variable to update it. That should make my code much less generic.
An example of the 2D matrix could be:
Var1 2.03
Var3 5
Var6 yes
Var2 23
Thanks a lot for your reactions!
Flip
Solved! Go to Solution.
01-27-2019 02:30 PM - edited 01-27-2019 02:35 PM
I would say No. Any local variable is implicitly bound to a specific control.
You could use a Value property node, this lets you use one that is unlinked to a control. You would just need to feed it a reference to the particular control you want. But you'd still have to figure out how to get the reference to a control by that name.
But better yet, you can use an Invoke Node called "Ctrl Val.Set"
There is also an OpenG subVI that will let you set a control value by name. called "Set Control Value {Variant}".
01-27-2019 03:25 PM
Thanks RavensFan.
It is supersimple in that way: just link a 'this vi' constant to the reference!
Flip
01-27-2019 03:29 PM
Actually you don't even need to do that. Leave the reference input unwired and it assumes "this VI".