View Full Version : How to create two dimensional array in PBasic?
02-05-2007, 11:12 PM
Hi everyone, is there someone know how to create two dimensional array in PBasic?
02-05-2007, 11:15 PM
With only 26 bytes of RAM memory TOTAL in the BS2, it would have to be a pretty tiny two-dimensional array.
So no, there's no way, PBasic only supports a 1 dimensional array.
Why, what did you want to do?
02-05-2007, 11:56 PM
Tq allanlane5 for ur reply. My purpose is to apply mapping method which i want to store value in XY coordinates system. So do u have any idea about this?
02-06-2007, 12:12 AM
You might be able to use part of the program EEPROM to store your array as long as you don't change the values too much since it's possible to "wear out" memory locations if they're written too many times. Read the section of the manual on the READ/WRITE commands. You still only get a linear address space, but you can always compute your own subscripts. Say you want a 16 x 16 coordinate system and you're going to store the array starting at location ZZZ in the EEPROM. To read a location into a variable W, you can do "READ ZZZ+X*16+Y,W". This assumes that X and Y will range over 0-15 and the values are bytes (not 16-bit words).
02-06-2007, 12:20 AM
Tq Mike Green, thanks for ur reply, that is good idea, i will try to do that.