Shop OBEX P1 Docs P2 Docs Learn Events
Lookup Table - help needed — Parallax Forums

Lookup Table - help needed

computer guycomputer guy Posts: 1,113
edited 2009-01-10 12:04 in Propeller 1
Hi there,


I want to read 2 strings from a text file and store them in a form of lookup table.
I can already read the strings in but need help with the lookup table.


e.g

Text file:
Temp, Foo
Hello, Temp2




lookup:
v1 := lookup("Temp")
print(v1)




Gives output:
Foo





Thank you smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Building Blocks To The Propeller Chip A web site designed to help people who are new to the propeller chip.

Guitar Hero controller using the prop (WIP) --> HERE

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-01-10 11:58
    Hello cg,

    you have to reserve memory for the strings in RAM.

    VAR
      byte ByteArrayStr1[noparse][[/noparse]40]
      byte ByteArrayStr2[noparse][[/noparse]40]
    
    
    
    



    You can do this definining a byte-array or defining an "empty string"
    = memory filled up with zeros

    DAT
      Str1 byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0
      Str2 byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0
    
    
    



    then you have to store the string bytewise into the array or the DAT-memorysection

    "printing" strings (with FullDuplexSerial, TV_text etc.) works via a pointer which contains the memoryadress of the RAM where the string begins and has to be ALWAYS terminated with a zero

    best regards

    Stefan
  • computer guycomputer guy Posts: 1,113
    edited 2009-01-10 12:04
    Thank you Stefan. smile.gif

    I think I have enough information to complete the project now.
    The information I needed was right under my nose.
    Thank you for pointing it out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Building Blocks To The Propeller Chip A web site designed to help people who are new to the propeller chip.

    Guitar Hero controller using the prop (WIP) --> HERE
Sign In or Register to comment.