Spin2 Structures used as multidimensional arrays?
ke4pjw
Posts: 1,169
in Propeller 2
Can spin2 structures be used as multidimensional arrays? I had it in my mind that they could be, but when I dug into the syntax, that may not be the case.
BTW, reading through the current version of the Spin2 Document, I see so many things that I have ignored or didn't know about. Enumerated constants and comma-separated declarations are really cool.
Comments
I wouldn't think so, and you may want to hold off on P2 structures until Chip and the other compiler writers finalize implementation.
Agreed. In may game device programs I use them to define states.
My main() method is often as simple as
Of course, gameState is a global variable so it can be modified as required by any active state.
Thanks Jon! I believe I have made a workaround, as the array that I am attempting to enumerate is simple.
Since clarity is a big driver of how I write code you might consider access methods. As the king of simple code, I've done things like this:
Then use methods that are this simple. Using a method adds a bit of overhead, but provides a lot of clarity.
That's exactly what I did, except I didn't make it generic. There is only one multidimensional array and it has 12 columns.
i remember chip using square brackets on each level in his demo, but not not how to declare them