LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reshape size of array by using control reference

Solved!
Go to solution

Hi,

 

I can't figure out how to reshape an array which is accessible through control reference.

 

In the VI there is a cluster, which contains few array controls (array types include floating point, INT32, etc.) and through property node Controls[] I get an array of references to all of them. The goal is to resize/reshape the arrays through these references. Here is the code I'm using:

Lubenhristov_0-1707396102199.png

The problem is that each time I'm trying to change the array size (and the new size is different from the existing one) I get error 0x5B.

 

I'll appreciate any ideas how to solve this problem. Thank you!

 

P.S.
Just found that the error occurs ONLY when increasing the size of the array (for example the initial 1D array has 5 elements and I want to change the size to 6). It doesn't occur when decreasing the size (cropping) the array. 

 

0 Kudos
Message 1 of 4
(623 Views)
Solution
Accepted by Luben.hristov

@Luben.hristov wrote:

Just found that the error occurs ONLY when increasing the size of the array (for example the initial 1D array has 5 elements and I want to change the size to 6). It doesn't occur when decreasing the size (cropping) the array. 

 


If you grow the array, the new elements will be void variants. That won't work...

wiebeCARYA_1-1707401321830.png

Note how tricky Reshape array is: It will 'flatten' all data and not only reshape the 2D array, but also rearrange the elements. It's probably not what you want.

 

You'd need to get the element variant, and than, for instance, initialize a 2D array with that default element, and than replace the current data in it:

wiebeCARYA_0-1707401179932.png

 

Message 2 of 4
(595 Views)

Hi Wiebe,

 

Just on the spot - the problem was the misbehaviour of Reshape Array - despite that if applied directly to the array values the Reshape Array can increase or decrease the array size, in case of the array with variances something weird happens.

 

Thank you so much!

0 Kudos
Message 3 of 4
(589 Views)

@Luben.hristov wrote:

Just on the spot - the problem was the misbehaviour of Reshape Array - despite that if applied directly to the array values the Reshape Array can increase or decrease the array size, in case of the array with variances something weird happens.


That is how Reshape Array always works: it flattens the data and reshapes it. With other data types Reshape Array will also fill up the missing data with the element's data type's default value. For strings->empty strings, Booleans->FALSE, numerics->0, variants->void.

0 Kudos
Message 4 of 4
(582 Views)