I don't know if it's a bug or I'm not doing it right, but when I try to resize an array, it works for me if it has only one dimension, but not if it has more.
Code: [Local Link Removed for Guests]
wlog "array1:"
for i = 1 to 5
dim array1(i)
array1(i) = i
next i
for i = 0 to 5
wlog array1(i)
next i
wlog " "
' ------------------
wlog "array2:"
for i = 1 to 5
for j = 1 to 5
dim array2(i, j)
array2(i, j) = i
next j
next i
for i = 0 to 5
wlog "----"; i
for j = 0 to 5
wlog array2(i, j)
next j
next i
I don't know exactly what do you expect from your "bizarre" code, probably to recover the old values in the new array?
Unfortunately this can work only with single dimension array as changing multiple dimensions the memory is allocated differently.
Perfect, that's what I wanted to know. Although it was what I suspected given the result of my code.
Well, nothing, perhaps it should be explained in the Help, since it only says: <<The arrays can be re-sized using the same DIM command.
In this case all the existing elements will maintain the previous value except the new elements that will be initialized at 0 or null string. >>
And it may confuse you into thinking that it refers to all types of arrays.
As you know, the "dimensions" do not exists in memory as the "multiple dimensions" arrays simply points in block of linear memory. So, in case of single dimension, it is easy to maintain the old values but on multiple dimension, the interpreter should move and recompose the new array with the old values, dimension per dimension ... a big effort for a negligible need
I understand and I totally agree with you. It's simply that I'm investigating all the "nooks and crannies" I can of Annex.
In my case, I was trying to read a file line by line and add dimensions to the array that will contain it to adjust the memory to the minimum necessary.
But it is much easier to find out in advance how many lines the file has and then size the array accordingly.
Or do without arrays and work with file.read_iobuff.