LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determining if variant is 1D or 2D array

Solved!
Go to solution

Hello,

 

I'm writing a program which parses data from a large input cluster so it can be written to a more well known format for reading later. I am trying to find a way to determine if a variant is a 1D array or a 2D array.

 

I have written a routine which will determine if the variant is an array, as well as the type of array (dbl, i32, etc), however I am not sure how I can tell if the array is 1D or 2D so I can know what I should to wire up on the 'variant to data' block's 'type' terminal.

 

When I look at the variant as an indicator, if it is a 2D array is see something like [33x236], if the array is a 1D array I see something like [256], but is there any way to programmatically tell if I am dealing with a 1D array or 2D array? Sorry if I am missing something obvious.

 

Any insight is much appreciated!

 

Best Regards,

Michael

 

0 Kudos
Message 1 of 5
(3,241 Views)

Ok, so I figured out a way to do this based on the flatten to XML block, however I'm wondering if there is a more elegant way? 

 

Any insight is much appreciated!

0 Kudos
Message 2 of 5
(3,231 Views)
Solution
Accepted by topic author mkabatek

Look at the VIs in <vi.lib>\Utility\VariantDataType


___________________
Try to take over the world!
Message 3 of 5
(3,221 Views)

Awesome! That is much easier than what I wrote myself. Thank you tst! BTW what's up with these locked VIs? Are they NI proprietary? I'm wondering if they actually use flatten to XML and parse it anyways, or they have some NI tricks.

 

Regardless thanks again! You have been very helpful!

0 Kudos
Message 4 of 5
(3,199 Views)

@mkabatek wrote:

Are they NI proprietary? I'm wondering if they actually use flatten to XML and parse it anyways


Yes to the first and "probably no" to second. If the second was "yes", then the VI would probably not be locked.


___________________
Try to take over the world!
0 Kudos
Message 5 of 5
(3,187 Views)