From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Intaris

Array size via Property node

Status: New

When developing a  utility to traverse any control using VI Server and save its contents to a file (similar to the OpenG utility using Variant) it is quite challenging to find out the size of the array's data.

 

There are various workarounds, but all of these are relatively tedious and over-complicated.

 

Why don't we have a "array data size" read only value on the property node of an array?

 

This would make things MUCH easier.

 

Shane.

Message Edited by Intaris on 06-12-2009 12:33 PM
5 Comments
AristosQueue (NI)
NI Employee (retired)
By this you mean "how many elements of the are displayed" right?
Intaris
Proven Zealot

No, I mean the data size of the array.

 

If I pass a reference to an Array to a Sub-VI I have to use variant tools to get the size of the Array which automatically means a data copy in memory which can be quite resource-hungry depending on what size the array is (Which you can't know beforehand....Catch 22).

 

Shane.

Intaris
Proven Zealot

No more comments?

 

Nobody else needs to parse Arrays from a VI Server reference?  There was a discussion on it on the NI Forum a while back.

 

See HERE for more information on the discussion (or especially the posts leading up to HERE).  Ben's Nugget shifted to an ugly fact that the only way to get the  size of an array is via the Value variant, a horribly inefficient (and depending on the size of the array potentially disastrous) operation.

 

Shane.

Message Edited by Intaris on 06-17-2009 01:44 AM
jhmaloney
Member

I know that this is an older thread, but I've been working on the same problem and this, and the links in intaris' comments seem to be the only information i can find. So once I figured something out, i figured it was useful to put it up and share.

 

I've been working on a similar VI, one which can save and load "any" control as a human readable configu file. Ive found a solution to this problem that is a little less cumbersome, but not as flexible (it requires that you know the dimentions of any arrays).

 

Capture.JPG

(method for finding the size of a 1d array from a variant)

 

 

This code uses the flatten variant to flatten out the array. Originally I thought to use the type string array of I16 values, but if you read up on the variant to flattened string, it says that labview stores the size of the array in the array data itself. So you need to take the data string and convert it to an array of U8 bytes and find the array size in there. This is why this method isn't super flexible. The array stores it's size in the Row major order, so as you increase the dimentions of the array, the location of the size bytes for each dimentions is variable. But for 1d arrays, it works very well. I could imagine it being expanded to handle 2d arrays as well.

 

-Joe

Intaris
Proven Zealot

This workaround is known but creates an extra copy of the array data.  In fact there are similar more robust methods Where the nr of dimensions do not need to be known.