
-----------------------------------
skier
Tue Nov 16, 2004 6:53 pm

adding to a 2d array
-----------------------------------
how do i add 1 to the 1..3 par to make it 1..4 


var stuff : flexible array 1 .. 3, 1 .. 6 of string

***new stuff, upper (stuff) + 1,***
    


the part that doesn't work is ***

-----------------------------------
Mr. Glib
Tue Nov 16, 2004 8:51 pm


-----------------------------------
I don't believe Turing will allow for the complex multi-dimensional array reallocation as of yet. Can someone verify this?

-----------------------------------
zylum
Tue Nov 16, 2004 9:59 pm


-----------------------------------
nope they dont

-----------------------------------
Mazer
Wed Nov 17, 2004 1:08 pm


-----------------------------------
Maybe I misunderstand...
var stuff : flexible array 1 .. 3, 1 .. 6 of string

put "initialize elements"
for i : 1 .. upper (stuff)
    stuff (i, 1) := "checking " + intstr (i)
end for

put "outputting elements"
for i : 1 .. upper (stuff)
    put stuff (i, 1)
end for

put "new element"
new stuff, upper (stuff) + 1, 6
stuff (upper (stuff), 1) := "new 4"

put "outputting elements"
for i : 1 .. upper (stuff)
    put stuff (i, 1)
end for

A two dimensional array is just an array in which each element is another array. Changing the dimensions means adding another array to the end, or taking one off. Unless you are trying to change the size of the second arrays (that is, the ones inside the main array) in which case you Mr. Glib is right.

Complex multi-dimensional flexible array reallocation not implemented yet - sorry.
