01-04-2011 04:18 PM
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
01-04-2011 04:30 PM - edited 01-04-2011 04:32 PM
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.
01-04-2011 04:45 PM
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?
01-04-2011 09:25 PM
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!
01-05-2011 10:52 AM
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?
01-05-2011 10:57 AM
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