
-----------------------------------
r0ssar00
Thu Jan 26, 2006 8:09 am

have flexible 2d array, need to add element
-----------------------------------
i need to add an element to my 2d array in my program, and it wont add
heres my code

var file:int
var fileString:string
var tmpFile:flexible array 1..1, 1..1 of string
open : file, fileString, get
var i :string:= 1
loop
    exit when eof (file)
    get : file, tmpFile (1, i)
    new tmpFile, upper (tmpFile (0,1) + 1)
    i += 1
end loop

the one thing i really need to have happen is to add a new string value thingy to both dimensions
thanks

-----------------------------------
MysticVegeta
Thu Jan 26, 2006 11:33 am


-----------------------------------
You cannot add elements to a 2D flex array. How ever I think someone did it, not sure who it was but it must be somewhere around here.

-----------------------------------
r0ssar00
Thu Jan 26, 2006 11:37 am


-----------------------------------
so, essentially, i need to have a superhuge 2d array to encompass all ill need to do, in the range of 32000, fun use of memory, sorry for the sarcasm

-----------------------------------
MysticVegeta
Thu Jan 26, 2006 11:44 am


-----------------------------------
yes and dont forget to increment a counter variable every time you insert something into that array, cause if you are using that array and you go :

for x : 1..10
put arra(x)
end for


All the 10 elements might not have been filled so it will give you an array of bounds error.

-----------------------------------
Andy
Thu Jan 26, 2006 12:56 pm


-----------------------------------
for two d arrays, you can only change the first parameter.. ie if u have an 2x3 flexible array, you can only change the 2, not the 3

-----------------------------------
do_pete
Thu Jan 26, 2006 1:34 pm


-----------------------------------
You can change it in Turing 4.1

-----------------------------------
Albrecd
Thu Jan 26, 2006 1:35 pm


-----------------------------------
If you have Turing 4.1 or greater you can use a flexible multidimentional array and then use new arrayID, upperbound1, upperbound2...  to resize it.

-----------------------------------
r0ssar00
Thu Jan 26, 2006 2:54 pm


-----------------------------------
i just realized that i had been going about this all wrong, i dont need a 2d array, i just need two arrays, thanks anyway

-----------------------------------
Cervantes
Thu Jan 26, 2006 4:33 pm


-----------------------------------
for two d arrays, you can only change the first parameter.. ie if u have an 2x3 flexible array, you can only change the 2, not the 3

You can change the two, you just have to be quite tactful.  
Flexible Arrays Tutorial
 You can change any upper bounds from a 0 to x, or from x to 0.
 If you change one upper bounds to a zero, you can do whatever you want with the other upper bounds.
 In a 2D array, if you leave the second upper bounds alone, you can change the first upper bounds


You could do it by changing the first bounds to zero, then to whatever you want.  Or you could do it by changing the second bounds to 0 and the first to whatever you want, then changing the second back to 3.  However, storing the data in the array while you're doing all this would be an even bigger pain.

-----------------------------------
r0ssar00
Fri Jan 27, 2006 1:10 pm


-----------------------------------
so ur saying i could do this 

var tmpData:flexible array 1..1, 1..1 of string
new tmpData, upper(tmpData) + 1, upper(tmpData) 
new tmpData, upper(tmpData), upper(tmpData)+1 


but not this 


var tmpData:flexible array 1..1, 1..1 of string
new tmpData, upper(tmpData) + 1, upper(tmpData) + 1 


right?

-----------------------------------
Cervantes
Fri Jan 27, 2006 4:41 pm


-----------------------------------
Almost, I think.

so ur saying i could do this 
...
new tmpData, upper(tmpData), upper(tmpData)+1 


That line violates the rules.  But if it works (in a non-4.1 version), then the rules are wrong. Did it work for you?

-----------------------------------
[Gandalf]
Fri Jan 27, 2006 8:12 pm


-----------------------------------
If you have Turing 4.1 or greater you can use a flexible multidimentional array and then use new arrayID, upperbound1, upperbound2...  to resize it.
Really?  :shock: Dang, this is finally a useful update (either than gif support).  Too bad they didn't update the help file.

Thanks for the info!
*tries it out*

-----------------------------------
r0ssar00
Sat Jan 28, 2006 1:56 pm


-----------------------------------
it didnt work, thanks anyway
