multi dimentional arrays?
RottenJalapeno
Posts: 27
I was wondering if it is possible to make multidimentional arrays for variables?
What I am trying to do is have a list of 50 names (strings, 16 chars long), and have·information associated with each name,·that I can modify, and also index.
There might be an easier way to do this but I would think the easiest way would to through all the data into an array.
Any suggestions would be nice,
Thank you parallax, and all you parallaxers out there that helped me on several occasions
Jeremy
What I am trying to do is have a list of 50 names (strings, 16 chars long), and have·information associated with each name,·that I can modify, and also index.
There might be an easier way to do this but I would think the easiest way would to through all the data into an array.
Any suggestions would be nice,
Thank you parallax, and all you parallaxers out there that helped me on several occasions
Jeremy
Comments
Your 50 x 16 array is the same as a single array of 800 and you can replace all myArray[noparse][[/noparse]x,y] with myArray[noparse][[/noparse] x * 16 + y ]. You can also use helper methods to set and get array items ...
Not perfect but possible workrounds.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."
- Bjarne Stroustrup
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
If so, for x = 0 to X, y = 0 to Y, z = 0 to Z
myArray[noparse][[/noparse] x * ( (Y+1)*(Z+1) ) + y * (Z+1) + z ]
( keeping my fingers crossed I've got that right )
hippy said..............
VAR
· byte myArray[noparse][[/noparse]800]
800 Linear bytes(X00000y00000y00000X00000y00000y00000X00000y00000y00000X00000y00000y00000X00000y00000y00000)
·You can break it in logic ARAY elements
X1 (X00000y00000y00000
X2 (X00000y00000y00000
X3 (X00000y00000y00000
X4 (X00000y00000y00000
X5 (X00000y00000y00000
etc....
PUB Main | i
· i := Get_myArray(10,12)· ' myArray[noparse][[/noparse]1,1] := myArray[noparse][[/noparse]10,12]
· Set_myArray(1,1,i)
PRI Get_myArray(x,y)
· return myAray[noparse][[/noparse] x * 50 + y ]
PRI Set_myArray(x,y,value)
· myArray[noparse][[/noparse] x * 50 + y ] := value
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
Post Edited (Sapieha) : 9/30/2008 12:33:45 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
I really want to thank all of parallax for their free software, object exchange, and forums. They have helped me greatly in this project and the projects before. I am still learning a great deal during every project, and I hope one day I can put my 2 pennies back in the jar of knowledge. Thanks again parallax, you rock.