Multi Dimension Arrays? Do we have them?
TJHJ
Posts: 243
So I could have sworn I say something in the propeller manual about this, but I can not seem to find it again.
It C++ as an example, and if spin becomes C++, someone kill me.
so really Ive got a 50 length array, that is accessed nicely from 0-9 and 0 -5.
Now for spin I tried defining it as
it doesn't like that.
So I keep wracking my brain and I cant seem to find a simple way to do this in spin. The best idea I have come up with is the following.
But that just seems fair as a solution at best, is there a better way to do this?
Thanks as always
TJ
It C++ as an example, and if spin becomes C++, someone kill me.
SIZE_X = 10 SIZE_Y=5 int array[noparse][[/noparse]SIZE_X][noparse][[/noparse]SIZE_Y];
so really Ive got a 50 length array, that is accessed nicely from 0-9 and 0 -5.
Now for spin I tried defining it as
long array[noparse][[/noparse]SIZE_X] [noparse][[/noparse]SIZE_Y]
it doesn't like that.
So I keep wracking my brain and I cant seem to find a simple way to do this in spin. The best idea I have come up with is the following.
long array[noparse][[/noparse]50] pub acessArray(x, y) return array[noparse][[/noparse]x*10+y]
But that just seems fair as a solution at best, is there a better way to do this?
Thanks as always
TJ
Comments
Homespun does support multidimensional arrays. The syntax is arr[noparse][[/noparse]i,j] instead of arr[noparse][[/noparse]j].
No. The compiler in bst is released as a command line component called bstc. It's a completely different beast and does not support the multi-dimensional array extension.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pull my finger!