Computer Science Canada have flexible 2d array, need to add element |
Author: | r0ssar00 [ Thu Jan 26, 2006 8:09 am ] | ||
Post subject: | 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
the one thing i really need to have happen is to add a new string value thingy to both dimensions thanks |
Author: | MysticVegeta [ Thu Jan 26, 2006 11:33 am ] |
Post subject: | |
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. |
Author: | r0ssar00 [ Thu Jan 26, 2006 11:37 am ] |
Post subject: | |
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 |
Author: | MysticVegeta [ Thu Jan 26, 2006 11:44 am ] | ||
Post subject: | |||
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 :
All the 10 elements might not have been filled so it will give you an array of bounds error. |
Author: | Andy [ Thu Jan 26, 2006 12:56 pm ] |
Post subject: | |
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 |
Author: | do_pete [ Thu Jan 26, 2006 1:34 pm ] |
Post subject: | |
You can change it in Turing 4.1 |
Author: | Albrecd [ Thu Jan 26, 2006 1:35 pm ] |
Post subject: | |
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. |
Author: | r0ssar00 [ Thu Jan 26, 2006 2:54 pm ] |
Post subject: | |
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 |
Author: | Cervantes [ Thu Jan 26, 2006 4:33 pm ] |
Post subject: | |
Andy wrote: 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. Cervantes, in the Flexible Arrays Tutorial wrote:
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. |
Author: | r0ssar00 [ Fri Jan 27, 2006 1:10 pm ] | ||||
Post subject: | |||||
so ur saying i could do this
but not this
right? |
Author: | Cervantes [ Fri Jan 27, 2006 4:41 pm ] | ||
Post subject: | |||
Almost, I think. r0ssar00 wrote: so ur saying i could do this
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? |
Author: | [Gandalf] [ Fri Jan 27, 2006 8:12 pm ] |
Post subject: | |
Albrecd wrote: 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? ![]() Thanks for the info! *tries it out* |
Author: | r0ssar00 [ Sat Jan 28, 2006 1:56 pm ] |
Post subject: | |
it didnt work, thanks anyway |