Shop OBEX P1 Docs P2 Docs Learn Events
Parsing a Variable — Parallax Forums

Parsing a Variable

s2jesses2jesse Posts: 62
edited 2005-07-18 19:18 in BASIC Stamp
Hello,

Im trying to parse a variable but not sure how to do it.

I need to find a way to do a for loop on each character of a variable. so i can pass each char out to an lcd individually.

for instance

message "hello please parse me"

for "each letter in messge"

something like
READ message + index, char (however read works on eprom and i dont want to read it from eprom

Hope that made some sense.
Thanks Jesse

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-18 17:34
    Jesse,

    ·· What you're trying to do can't be done with a variable.· You could put the DATA into EEPROM and read it one character at a time from there.· In the BASIC Stamp Editor, please click on help, and PBASIC Syntax, then click on the READ command.· In the example link is code to do what you're talking about.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • s2jesses2jesse Posts: 62
    edited 2005-07-18 18:00
    Hrm ok bummer yeah i figured out how to use the read but i didnt want to use eprom cause the variables i need to print out in my application will be changing constantly.

    Thanks though.
    Jesse
  • YanroyYanroy Posts: 96
    edited 2005-07-18 19:03
    If you have some set messages you want to print out, those should be stored in EEPROM.· But if you're generating your messages dynamically, a RAM variable is probably what you're looking for.· If you're willing to sacrifice a large chunk of your RAM, you could make a large array to store the message.

    MyArray var byte(size) ' where size is how many characters you want in your message

    Then you'd go through it with a for..next loop like this:

    for n = 0 to size

    MyArray(n) = 1 'instead of storing 1, you'd probably want to do something actually useful like output to the LCD

    next
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-18 19:18
    ·· Which BASIC Stamp Module do you have?· If you have one that has Scratch Pad RAM, you could use that memory and use the GET/PUT instructions.· You can also use an array (Variables) but that would depend on how much data we are tlaking about at most (How many bytes), since you only have 26 bytes to start with, total.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.