12-09-2009 06:55 AM
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.
Solved! Go to Solution.
12-09-2009 07:25 AM
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.
12-09-2009 08:11 AM
12-10-2009 04:19 AM
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,
Aurélien J.
National Instruments France
12-10-2009 04:51 AM
Hi Daniel,
From the delete array help page:
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
12-10-2009 05:01 AM
12-10-2009 06:45 AM
> 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
03-05-2010 04:55 AM