08-22-2023 05:15 AM
Hi,
I Was trying to delete all elements from an array using "Delete From Array" by connecting rows & length. Since I have deleted all elements from array, the output "Array w/ Subset deleted" should be empty and its expected array size is "0*0". But here output array is empty, and its array size is retaining as source array size. What will be the reason for this. Is it a bug?
Here am attaching the image also.
08-22-2023 05:20 AM
@Alwin_Capsys ha scritto:
the output "Array w/ Subset deleted" should be empty
This output IS empty (as per your image), so what's the problem?
08-22-2023 05:32 AM
For a multi-dimentional array, its size is the product of all of the dimension sizes. So the number of elements in your "deleted array" is 0 x 3 = 0.
An interesting "experiment" to try is to delete by columns instead of by rows. My guess (I'll let you find out if I'm right) is you'd end up with an array of 2 rows and 0 columns, whose size is also 2 x 0 = 0. I also predict this will generalize to arrays of any dimension (you already know it's true for dimension 1 ...)
Bob Schor
08-22-2023 05:33 AM
Then output array size should be "0*0".
But I am getting array size as "0*3". Why it is because?
08-22-2023 05:49 AM
I think, whatever you have mentioned is right. But it doesn't meet my requirement.
08-22-2023 06:17 AM
Hi Alwin,
@Alwin_Capsys wrote:
whatever you have mentioned is right. But it doesn't meet my requirement.
So the problem is your requirement/expectation…
What exactly is your requirement? The ArraySize function already tells you the array contains "0" elements…
08-22-2023 07:01 AM
Sorry for missing the details.
Since I am using this in a shift register, whenever data comes in the next iteration (if it is lesser array size - expected array size is the array size of incoming data), it automatically creates array size matching with this size. So extra columns getting added.
Below am attaching the recreation of this bug as a VI. Please explain me, why 0's getting added as column in the output array even my source array size is always "10*5".
08-22-2023 07:38 AM
08-22-2023 08:16 AM
Det problem does not seems to be with the delete from array, but a "Insert into Array" in combination with your delete.
If you remove/disable the Insert into Array, then it will function as you expect.
08-22-2023 08:24 AM
@Alwin_Capsys wrote:
Then output array size should be "0*0".
But I am getting array size as "0*3". Why it is because?
The Delete From Array only subtracts the size from one index. In your case, it is subtracting 10 from the row index size, leaving it as 0, but the column size is not affected. Then when you come back around, the Build Array adds to both sizes. The Insert Into Array only adds to the column size, leaving the row size alone.
I know this has been hammered out many times on this board. I just don't have the time to dig at the moment.