LV 2013, Win7
Starting from a control reference, I need to traverse a data structure of arbitrary complexity, in order to produce a list of NAMEs and VALUEs (variant) for each element.
Simple control tyoes are easy:
I get the NAME (label) and append to the prefix I started with, and then get the VALUE, which is already a variant.
Append those to the array:
![Convert 1.PNG Convert 1.PNG]()
-----
If the thing is a CLUSTER, then it's not difficult either.
I simply cast the reference to a CLUSTER ref, get the controls from it, and recursively call myself for each one:
![Convert 2.PNG Convert 2.PNG]()
-----
However, if the thing is an ARRAY, then I'm stumped.
I know that if I ask for the VALUE of an array, I get a single VARIANT, which contains all the elements values.
But that's not acceptable for my purpose (assigning a PROPERTY in a TDMS file).
I know that there is really only one element in an array (as far as properties go).
But I need to build a name, and a variant value, for every element in the array.
And the element might be a boolean or a cluster, so I need to recurse using a reference to the individual element.
I tried setting the INDEX VALS property before accessing the ARR ELEM property, but...
1--- That changes the on-screen view, which I don't like, and
2--- it doesn't work.
When I set the INDEX to 0, and use the ARR ELEM to get the VALUE, I get the value of the last element (#2).
After that, I get 0.
![Convert 3.PNG Convert 3.PNG]()
So how can I get a reference to a given element, so that if I recurse, I get the values from that one element?
How can I figure out how many elements are in the array ? (remember that I don't know what type of array it is) ?