LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 dimension array size error

Solved!
Go to solution

Hello,

In attached file a exemple of my problem. I delete a 2 dimension array and display the size. I can notice in "size 2" (see the exemple") that the size is not at 0. Is It a normal behaviour?

Thanks in advance, Daniel.

0 Kudos
Message 1 of 8
(4,507 Views)

In the first example with the 2D array what you see is that the array is 2D and it has 0 entries.

 

The second is a 1D array with no entries.

Tim
GHSP
0 Kudos
Message 2 of 8
(4,493 Views)
The problem is in the first example/case. After deleting the array, "size2" is at 2;0. I think that the value of "size2" would be 0;0 because the array is empty. What is your opinion?
0 Kudos
Message 3 of 8
(4,475 Views)

Hello,

 

in your first exemple, you array is array of 2 lignes and 1 column. You delete 1 column so the array is 2 lignes and 0 colums (2:0) . It's normal behaviour.

 

regards,

0 Kudos
Message 4 of 8
(4,428 Views)
Solution
Accepted by topic author daniel_blanzat

Hi Daniel,

 

 

From the delete array help page:

"Delete From Array Details

This function reduces the array in one dimension only..."

 

 

So even though your array "looks" empty, it really isn't. I'm guessing that the memory for the rows is still allocated.

 

You can see this by connecting the array to a for loop and checking how many times it iterates (i.e. twice).

To really empty the array, you could add another Delete from Array function and delete the rows (length = 2, index = 0). Now connect this to a for loop and you will see it does not iterate. The array sizes will now be at 0,0.

 

A bit odd at first, but in the end it is expected behavior.

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
Message 5 of 8
(4,423 Views)
So, there is no link between the display and the size array function. I find it a little puzzling..
0 Kudos
Message 6 of 8
(4,421 Views)

> So, there is no link between the display and the size array function

 

I guess you are right - the display shows values - not memory allocation.

 

One could make the case that it would be nice if the Delete from Array function was smart enough to realize that you just deleted the last of the array so why not get rid of any remaining rows/columns. On the other side of the coin, the Delete from Array function is not intended to be a Delete Array function and there may be performance issues on large arrays to add that functionality.

 

To be honest, I was a bit puzzled by this until I saw the help documentation (i.e. rows or columns - not both). That's when I decided to check the array to see if it really was the size that was reported - and it was.

 

You can also see this same functionality if you make an 2D array constant on the block diagram. Set values for the first column. Then right click and pick delete column. The array appears empty. Now enter a value in row zero, column zero. You will see that values for all of the rows you had previously set will be created. The memory for the rows was retained. 

 

 - very interesting find Daniel.

 

steve

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 8
(4,408 Views)
I just came across this "functionality". And I really think that the reshape to zero if last element is deleted should be implemented otherwise it is very confusing. Even the 'Is EmptyArray' primitive shows the array as empty. LV2009 SP1
LV 2011, Win7
0 Kudos
Message 8 of 8
(4,217 Views)