Shop OBEX P1 Docs P2 Docs Learn Events
How to create two dimensional array in PBasic? — Parallax Forums

How to create two dimensional array in PBasic?

jiunn82jiunn82 Posts: 5
edited 2007-02-05 16:20 in BASIC Stamp
Hi everyone, is there someone know how to create two dimensional array in PBasic?

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-02-05 15:15
    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?
  • jiunn82jiunn82 Posts: 5
    edited 2007-02-05 15:56
    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?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-05 16:12
    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).
  • jiunn82jiunn82 Posts: 5
    edited 2007-02-05 16:20
    Tq Mike Green, thanks for ur reply, that is good idea, i will try to do that.
Sign In or Register to comment.