Shop OBEX P1 Docs P2 Docs Learn Events
Multi Dimension Arrays? Do we have them? — Parallax Forums

Multi Dimension Arrays? Do we have them?

TJHJTJHJ Posts: 243
edited 2008-11-07 03:39 in Propeller 1
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.
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

  • mparkmpark Posts: 1,305
    edited 2008-11-07 02:35
    In regular Spin, that's pretty much what you have to do.

    Homespun does support multidimensional arrays. The syntax is arr[noparse][[/noparse]i,j] instead of arr[noparse][[/noparse]j].
  • TJHJTJHJ Posts: 243
    edited 2008-11-07 03:02
    Isnt BST using the homespun compiler? I keep getting a compiler error from it.
  • BradCBradC Posts: 2,601
    edited 2008-11-07 03:39
    TJHJ said...
    Isnt BST using the homespun compiler? I keep getting a compiler error from it.

    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!
Sign In or Register to comment.