キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

2 dimension array size error

解決済み
解決策を見る

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 件の賞賛
メッセージ1/8
5,987件の閲覧回数

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 件の賞賛
メッセージ2/8
5,973件の閲覧回数
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 件の賞賛
メッセージ3/8
5,955件の閲覧回数

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 件の賞賛
メッセージ4/8
5,908件の閲覧回数
解決策
トピック作成者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.
----------------------------------------------------------------------------------------------------------------
メッセージ5/8
5,903件の閲覧回数
So, there is no link between the display and the size array function. I find it a little puzzling..
0 件の賞賛
メッセージ6/8
5,901件の閲覧回数

> 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 件の賞賛
メッセージ7/8
5,888件の閲覧回数
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 件の賞賛
メッセージ8/8
5,697件の閲覧回数