LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

getting a single elment from a cluster

How can I retrieve a single elment from a cluster of different types? The cluster is going to be quite large so I would like to do this by using an index. That is to say, I would like a function that works on clusters like "Index Array" works for arrays. So far I've only found a function that does this by name which I've attached as an example.

 

Thanks in advance for your help!

Chad Johnson

0 Kudos
Message 1 of 6
(2,578 Views)

There is a cluster to array function. But to use it you have to have a cluster in which all elements are the same datatype. What you could do is to wire the cluster to an indicator so you can create a property node. Select the Controls[] property and index that. Wire the element to another property node and select Value. But what you will get is a variant so you still have to know the datatype of the element you indexed.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 6
(2,575 Views)

You cannot convert the cluster to an array, because you have different flavors of elements (e.g. boolean and numerics).

 

If you had a control or indicator of your cluster, you could get the controls[] property, which gives an array of references to all cluster elements in their cluster order. Index out the desired reference and do "something" with it. Your option will be limited.

 

Maybe it is time to redesign your data structures to a more useful format if this is an issue.

 

What exactly are you trying to do?

0 Kudos
Message 3 of 6
(2,558 Views)

The question is "The cluster is going to be quite large",maybe you can only use the function "Unbundle by name " to get what you want,or you can create a subVI by yourself.May you sucessed!

0 Kudos
Message 4 of 6
(2,532 Views)

Thanks for all of your answers. The problem is that the cluster is going to be quite large and contain objects of different types. I tried the suggestion of using the controls[] property and indexing off of that. It works but, as noted, there is no way to store the type of value which is being retrieved. If a cluster is not a good container for this purpose, then what is?

0 Kudos
Message 5 of 6
(2,492 Views)

If you want to look at a "I'm sorry I asked." reply to getting at thingies in a cluster, see this thread.

 

Please tell us more (or even better show) about your data and we'll be able to offer suggestions.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(2,488 Views)