2-D variable array
MacGeek117
Posts: 747
How do you make one with a BS2?
bugg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
But I canna change the laws of physics, Captain!
bugg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
But I canna change the laws of physics, Captain!
Comments
You can use a 1-dimensional array and some crafty coding.· Let's say you want a 2x3 array of bytes.
myArray········ VAR···· Byte(6········· ' 2 x 3 bytes
row············ VAR···· Nib
col············ VAR···· Nib
idx············ VAR···· Nib
Main:
· row = 0
· col = 2
· idx = row * 3 + col
· myArray(idx) = 10
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 3/9/2005 6:50:16 PM GMT
Here is a slightly more expanded version of that which I posted a couple months ago. The problem is that you can quickly run out of space as 26 bytes of variable will dissapear pretty quickly. This sample defines a 2x4 table of a two byte variable.
Jim
Edit: Actually, in looking at the code again, there is a glaring bug in how I set and retrieve the contents of the variable. I'm setting and retrieving a single byte, when the variable is supposed to be two bytes. But that doesn't change the basic concept of how the pointer works to get to the location in the array.
Post Edited (Jim McCorison) : 3/10/2005 1:19:52 AM GMT
Thanks Jon nd Jim!
bugg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
But I canna change the laws of physics, Captain!
1.) string type variable
2.) signed byte, word/integer, doubleword/long integer
3.) double/floating type variable