08-13-2010 06:22 PM
Good Morning Forums,
I have hit a brick wall with my application and I am hoping somebody can help!
I have an array of clusters of indeterminate size (the cluster is generic, data contained not relevant.).
Inputs to the VI are: a reference to the array, and a variant containing the data.
My problem is I need to determine the array size from these two inputs and I cannot find a way to do it!
If the array contained a standard data type I can use the class name property to determine data type, and the size of the array returned from "select size" property to determine dimension size. With this information i can cast the variant into the correct data type and use this to determine the size of the array. If the data is a cluster the class name simply returns "cluster" so I cannot cast the variant and therefore am unable to determine the size.
I am not worried about casting the data (once i determine the size this bit is no issue), I just need to determine the size (and preferably number of dimensions) of the array. Can this be done?
Cheers for any help
J
Solved! Go to Solution.
08-13-2010 10:18 PM
There's an OpenG VI that gets the # of array dimensions from checking the bits in the Type Descriptor output out variant to flattened string. Look in the VData package.
08-13-2010 10:29 PM - edited 08-13-2010 10:35 PM
08-14-2010 09:54 AM
@John.P wrote:
Good Morning Forums,
.
I am not worried about casting the data (once i determine the size this bit is no issue), I just need to determine the size (and preferably number of dimensions) of the array. Can this be done?
Cheers for any help
J
There seem to be a couple of potential solutions.:
#1 if the varient is created within LabVIEW you can wite size(s) to a varient attribute. This would be pretty straightforward and easy to implement- I imagine you would have thought of that so you may not have access to the code writing cluster to varient and it gets a bit trickier.
#2 cast the varient to string and return string length- this should give you a measure of total size and you would need to know the size per element of cluster (just cast one instance of cluster array to varient and then to string with size and size++) but this only returns the total size of the array since nDim arrays are actually stored sequentially.
Hope this helped
08-14-2010 12:25 PM
Cheers for the replies guys.
blawson, I wasn't aware of the OpenG VI but need to keep the code all standard LV as it will be used by people who will only have standard LV.
Matt, this was the best way to do what I wanted, casting the variant to an array of variants will give you the size of the array no matter what the array contains, and I could still use the "select size" property to determine number of dimensions.
Jeff, Thanks for the input, I had thought about variant attributes but as you rightly guessed I cannot implement this into the code that converts the cluster to a variant in the first place! Your second suggestion could work but require more code than Matts suggestions.
Thanks again.
J
08-14-2010 12:36 PM
I use the GetArrayInfo.vi from vi.lib myself.