Shop OBEX P1 Docs P2 Docs Learn Events
Looking up DAT Variables — Parallax Forums

Looking up DAT Variables

tdeyletdeyle Posts: 85
edited 2008-10-07 23:03 in Propeller 1
I am trying to display values from a variable stack in the DAT block by passing the address of the variables to another method, allowing me to display multiple screens without writing individual methods to display them.

Problem being, I keep getting random characters on the LCD screen with the following code:


PUB Main

Display2(@Bootscreen, BootScreen) 

PUB Display2(Address, Lines) | x, y 

debug.cls
y:=0

repeat lines
  
  repeat x from y to y+20

    debug.str(long[noparse][[/noparse]address][noparse][[/noparse]x+3])    
        
  y += 21

DAT

BootScreen    long      0, 4, 2,  "SPAT-               ", 0, "System Performance  ", 0, "and Adjustment      ", 0, "Terminal           ", 0





Any suggestions?

I have correctly displayed the values with this repeat loop, but cannot seem to get the MAIN method to pass them on correctly to the DISPLAY method.

Comments

  • tpw_mantpw_man Posts: 276
    edited 2008-10-07 21:39
    Indexing with LONG[noparse][[/noparse]addr][noparse][[/noparse]offset] indexes longs, not bytes. Also, any *.str method is usually built to handle byte strings, not long strings. Why did you use longs at all? I think that is your problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • tdeyletdeyle Posts: 85
    edited 2008-10-07 21:56
    The stack has to be in WORD or LONG in order for the string values to show up, no? I have changed the LONG in the DAT Stack to byte, but it does not work in the following code:

    pub Display2(Address, Lines) | x, y 
    
    y:=3
    
    repeat lines
      
      repeat x from y to y+20
    
        debug.str(@bootscreen[noparse][[/noparse]x])    
            
      y += 21
    
    
    
    



    However, it does work if I use WORD and LONG.
  • tpw_mantpw_man Posts: 276
    edited 2008-10-07 22:45
    I do not think you understand the concept of strings. Strings are for storing lengths of text. Strings end in zeros, and all *.str methods do something with the string and read it from the address to a zero. How exactly is the text supposed to look? I can help you more then.

    EDIT: And no, strings are always bytes. Your code should not work, but using words or longs was just luck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • tdeyletdeyle Posts: 85
    edited 2008-10-07 22:59
    Ok.

    I had a look back in the manual, I see where I went wrong. I removed the zeros from in between the separate strings and it displayed correctly.

    Thanks!
  • tpw_mantpw_man Posts: 276
    edited 2008-10-07 23:03
    You're welcome! From the looks of your code, you can now just go: debug.str(@bootmenu).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
Sign In or Register to comment.