LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in 'Build Array' function

There is a bug in the build array function. If you try to add a 1D array to an empty 2D array that was created also using the build array funcion and an empty 1D array constant, it treats the empty 2D array as if it had a single row of zeros with the same number of elements as the 1D array. However, if you use an empty 2D array constant, it works fine. See attached file.

Marty
0 Kudos
Message 1 of 6
(4,596 Views)
The build array function is working exactly as described in it's help file. Your error is in your assumption that a 1D empty array constant, built to a 2D array is the same as an 2D empty array constant.

The build array you use on the 1D empty array ouputs a 2D array of dimension 1x0 (not 0x0). When you then build use it to build your final array, it pads the 1x0 array with zeros to match the size of the second array.

~Tim
Message 2 of 6
(4,597 Views)
following up this conversation: if you look at the attached VI, how can you tell the difference of the two arrays? If you probe the wire, you will not see any. And the help says that "array size" should give the number of elements in each dimension. However, the array 1 seems to be as empty as array 2, isn't it. If array 1 is the output connector of an unkown VI, how can you tell if there is really something in the array (especially zeroes) or not?

Dirk
0 Kudos
Message 3 of 6
(4,576 Views)
...ok, if the array is empty or not may be checked easily by comparison against an empty string constant, giving different results for both cases. But the array size function still seems weird...
0 Kudos
Message 4 of 6
(4,569 Views)
Hi DirkLV,

You can tell if there is really something in the array or not by calculating the product of the number of elements in the row multiplied by the number of elements in the column.
See attatched example,

In your original example vi,
the output "size(s) 1" means "array 1" has three rows and zero columns (that means each row has no elements --> "array 1" empty);
the output "size(s) 2" means "array 2" has zero rows and zero columns (that means "array 2" empty).

Regards,

Xu
0 Kudos
Message 5 of 6
(4,550 Views)
Hi Xu,

you are right, this is obviously a very simple solution (I must have been too tired yesterday to see it :-)). Perhaps it would be a good idea if the wire probe would be extended by an additional indicator providing the array size, as otherwise you would not see the difference unless you use the array size function.

Thanks,

Dirk
Message 6 of 6
(4,528 Views)