06-09-2016 06:30 PM
Hi
I am trying to get a cluster element value from its variant form
If I look at the variant indicator, the elements and their values are displayed. However, after Get Cluster Information.vi, which I expect to break up the cluster into its individual elements, all I get is the type information, not the value of the element. That is, looking at the Elements array, all that is displayed are 0's, I was expecting values and element names.
So my question is, how do I get the cluster element values?
Thanks
Solved! Go to Solution.
06-09-2016 06:51 PM
One of my pet peeves is that Flattened String to Variant function does provide the remainder string, but with a bit of ugliness it can be worked around.
06-10-2016 04:22 AM
Autotestware Cluster Toolkit 2.0.0.4. You can granulate the 'Variant Data' output to your specificity with the 'Grains' input control. Or use Index Cluster (by Name).vi to return a single element.
06-10-2016 12:05 PM
Thanks Darin,
Unfortunately, I am not able to duplicate your results with the Variant/Flatten kludge. Does the LV 2015 Get Cluster Information.vi differ from your LV 2014 Cluster Info VI?
On a side note, why are variants treated like a secret shame? They are a fundamental part of LV and its only been recently that VIs to handle them were added to the official pallette. It seems to me that my application of them, getting the value from them, seems pretty basic yet the process seems like a kludge. Is there something fundamental in the background that prevents a native implementation of this?
06-10-2016 12:08 PM - edited 06-10-2016 12:09 PM
To AutoTestWare,
Thanks for your reply, but I am trying to get a value from a cluster variant not create a variant from a cluster. I looked at your set of cluster tools and did not see one that accomplished this. It is a nice set of tools but not appropriate for this application.
06-10-2016 12:39 PM - edited 06-10-2016 12:41 PM
Is there a reason you wish to avoid the OpenG tools that have been long available?
The OpenG LabVIEW Data package contains a VI entitled "Get Cluster Element by Name" (and a LOT of other VIs covering almost any need to handle varying datatypes at runtime).
The VIs found in <vi.lib>\Utility\VariantDataType may allow you to get there, though I've far less experience with using them, so I'd need to puzzle through them - they are somewhat "late to the party" vs. the OpenG implementation. Of course, they are NI-written vs. community-written, so draw your own conclusions.
But my first advice would be to fire up your VIPM and grab several of the workhorse OpenG packages.
Dave
06-10-2016 12:46 PM
@c_chip wrote:Thanks Darin,
Unfortunately, I am not able to duplicate your results with the Variant/Flatten kludge. Does the LV 2015 Get Cluster Information.vi differ from your LV 2014 Cluster Info VI?
![]()
On a side note, why are variants treated like a secret shame? They are a fundamental part of LV and its only been recently that VIs to handle them were added to the official pallette. It seems to me that my application of them, getting the value from them, seems pretty basic yet the process seems like a kludge. Is there something fundamental in the background that prevents a native implementation of this?
You need to wire the original variant to the flatten function instead of the output of 'Get Cluster Information'.
06-10-2016 01:36 PM
You need to wire the original variant to the flatten function instead of the output of 'Get Cluster Information'.
Aargh! Of course. Thank you. It now works.
06-10-2016 01:43 PM
Is there a reason you wish to avoid the OpenG tools that have been long available?
The OpenG LabVIEW Data package contains a VI entitled "Get Cluster Element by Name" (and a LOT of other VIs covering almost any need to handle varying datatypes at runtime).
I did look and there wasn't an obvious solution (to me, maybe to others) but after your post, I played with them a bit and found the "Cluster To Array of VData" is a more appropriate choice for my application.
Thanks for the input.
06-09-2017 02:03 AM
Basically a newbie question but what function do you use to display the values of variant data and element in that rectangle area on the block diagram?