06-04-2020 01:34 PM
I want to use the Variant data parsing tools to find the name of a control or indicator. The code is simple. See below.
If the code is run in the subVI I get the correct result. If run in the VIM I get the name of the VIM Control. If I try to use the subVI in a VIM, I get the name of the VIM control.
Can somebody let me know why this doesn't work in a VIM?
Thanks
mcduff
Solved! Go to Solution.
06-04-2020 01:54 PM - edited 06-04-2020 02:05 PM
Interesting...The tool works on an element inside a variant, but in the VIM, the variant is formed (by coercion at the input terminal of the tool) after passing trough the generic connector named "variant", so the content has the name of the input terminal
The VIM operates on the value of the control and the label is not part of the value. In the subVI version, the coercion to variant happens at the input, so the name is part of the variant data.
OTOH, This works:
06-04-2020 04:10 PM
It's interesting that one case works. However, for my end solution it will not work.
I wanted to wire different values to a configure file, have it automatically get the name of the control and write. I know there exist some variant solutions, I thought I could be clever and write a VIM.
Attached is the VIM, but you would need to rewire the name to make it work, otherwise all the names are "Value In". The Get Name from variant doesn't work as you noticed.
Thanks
mcduff
06-04-2020 04:44 PM
You might be interested in the long conversation on this idea (which is to make VIMs work the way you want). The idea was declined because NXG is eliminating wire/variant names entirely, making none of your solutions work, and so they want to discourage you developing code like this.
06-04-2020 04:52 PM
I still think that the current behavior is absolutely correct and is, as mentioned, caused by the difference where the coercion to variant occurs.
I don't see any valid workaround.
06-04-2020 05:33 PM
The other possible solution is to read the threads more closely. 😁
mcduff
06-04-2020 09:47 PM
Update
I think I found a Rube-Goldberg solution; @altenbach if you want to cross post it to the official R-G thread feel free. I have no idea if this work around will work in future versions.
You need to bundle the control you want in a single element cluster.
The VIM now looks like this:
An example is shown below (See how the string is put into a cluster):
Not ideal but working at the moment. Thanks for everybody's help.
mcduff
06-05-2020 12:07 AM - edited 06-05-2020 12:26 AM
@drjdpowell wrote:
You might be interested in the long conversation on this idea (which is to make VIMs work the way you want). The idea was declined because NXG is eliminating wire/variant names entirely, making none of your solutions work, and so they want to discourage you developing code like this.
So they're dumbing down LabVIEW NXG for the masses and LabVIEW Classic is paying for it. I guess this is why OpenG NXG support stopped at NXG 3.0 and MGI Tools stopped at NXG 2.0. I imagine this particular change broke about 1/3 of their tools.
06-05-2020 12:12 AM
@mcduff wrote:
Update
I think I found a Rube-Goldberg solution; @altenbach if you want to cross post it to the official R-G thread feel free. I have no idea if this work around will work in future versions.
You need to bundle the control you want in a single element cluster.
The VIM now looks like this:
An example is shown below (See how the string is put into a cluster):
Not ideal but working at the moment. Thanks for everybody's help.
mcduff
Yep. I came up with a similar "variant" to that solution. It's going to be a pain to maintain (which was what I was referring to in a post of mine, which was a "variant" of this one) because you will have to update everything manually, should anything change.
06-05-2020 02:16 AM - edited 06-05-2020 02:31 AM
@mcduff wrote:You need to bundle the control you want in a single element cluster.
Your input of a cluster of one element will work in NXG, as you will be able to get cluster element names; however, creating your cluster with a bundle will NOT work. Wires don't carry names, and so the bundle will contain an element named "Element 1". To get "My Control Name" you will have to create a cluster constant and manually configure the right name (and type), then bundle-by-name the value.