LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Type Parsing - Get Array Information does not return dimension sizes

I've started playing with the Data Type Parsing functions which are now available in the LabVIEW palette.  I thought these might be a substitute for the OpenG functions I currently use.  It seems that 'Get Array Information.vi' fails to return correct array lengths.  Array lengths for each dimension is always zero.  This seems like a bug.

 

Additionally, there does not seem to be any way to retrieve array elements of a multidemensional array as a 1D array of variant.  This would be very useful.  I found the "Set Array Information.vi' function, which is present in the vi.lib but was not included in the palette.  I tried to use that to redimension a multidemensional array as a 1d array, but it didn't seem to work.  Looks like I'll just have to keep using the OpenG functions.

0 Kudos
Message 1 of 5
(2,996 Views)

@codeman wrote:

I've started playing with the Data Type Parsing functions which are now available in the LabVIEW palette.  I thought these might be a substitute for the OpenG functions I currently use.  It seems that 'Get Array Information.vi' fails to return correct array lengths.  Array lengths for each dimension is always zero.  This seems like a bug.

 


This is not a bug -- it is the designed (and thus correct) behavior.  Have you read the Help for this function?

 

Bob Schor

0 Kudos
Message 2 of 5
(2,967 Views)

Regarding your second question: Isn't this what "Reshape Array" does? Or maybe I don't understand what you want to do?

0 Kudos
Message 3 of 5
(2,942 Views)

Good point, Per.  I seem to have "answered the question, but the wrong question".  If all that is needed is to get a multi-dimension array down to a one-dimension representation, that takes three functions -- array size, array product, and reshape array.  

 

Here is a Snippet that generates a 4x5x6 array, loads it with "index" numbers (000 in cell 0, 0, 0, 123 in cell 1, 2, 3) then does the Reshape trick to get a 1D array holding 0, 1, 2, 3, 4, 5, 10, 11, 12, ...  [You might notice that I create the array on the left of the nested For loop, then don't use it -- I'm using it as a "counter" for the For Loop -- 3D zeroed array in, 3D "defined" array out].

Reshape Array.png

Bob Schor

0 Kudos
Message 4 of 5
(2,938 Views)

Yes, I realize now that the "Get Array Information" function is returning the dimension size from the type descriptor rather than the actual array size; but with the parameter name being 'Array Lengths' you have to admit its a bit misleading. Also, since array types are nearly always 'Variable', the actual array sizes would likely be more useful.

 

At any rate, the goal was to convert a variant containing an array of any type and dimension to a 1D array of variant.  This is useful for certain types of generic data handling.  If you just wanted to reshape a normal array, you would use the Reshape Array function.

 

As I mentioned, there is a lot of overlap between the OpenG libraries and these new Type Parsing functions.  OpenG still seems to have a bit of an edge.  I thought it would make sense to have a function that returned the array elements similar to the way "Get Cluster Information.vi" returns all the cluster elements.  if anybody is looking for a boxed solution that does that, you can get the OpenG libraries from the VI Package Manager.  But if you did want to do it yourself, you could do something like this:

Array Reshape.png

Message 5 of 5
(2,919 Views)