Shop OBEX P1 Docs P2 Docs Learn Events
Can you store a string in a constant? — Parallax Forums

Can you store a string in a constant?

JomsJoms Posts: 279
edited 2010-03-07 04:24 in Propeller 1
Is this possible?

Con
  SerialNum          ="000012"
  TextCon            ="Test"




I looked in the Propeller manual but it only shows using a decimal. When I tried this in the software it gives me an exception error for this line. I refer to the serial number several times in the code and would like to enter it one time.

Is there an obvious work around for this?

THANKS!

Post Edited (Joms) : 3/7/2010 3:32:10 AM GMT

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2010-03-07 03:32
    Wouldn't you have to use a DAT, then provide an address?

    DAT mystring "1234"

    then refer to it as @mystring

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Safety Tip: Life is as good as YOU think it is!
  • JomsJoms Posts: 279
    edited 2010-03-07 03:57
    GREAT! I am getting close, but running into another little problem that I can't seem to fix...

    DAT 
      SerialNum  Byte 64, "SN:002211  V1.2"
    
    



    I then use
    PutStr(@SerialNum)
    

    in my program. It works, however I still see the "@" printed with the serial number. This shouldn't be happening because isn't that what shows where to point in the memory? Also, refering to the "64", is that how long the data is, or is that the exact location?
  • JackBakJackBak Posts: 45
    edited 2010-03-07 04:01
    strings need to be zero terminated
  • w8anw8an Posts: 176
    edited 2010-03-07 04:04
    Joms said...
    It works, however I still see the "@" printed with the serial number.

    Joms, why do you have the byte 64 preceding your SN string? That is the ascii code for "@"!

    Try this...

    DAT 
      SerialNum  byte "SN:002211  V1.2",0
    
    



    --Steve

    Edit--typo
  • JomsJoms Posts: 279
    edited 2010-03-07 04:24
    OK, That works better...

    I had the 64 in there because I was reading the book wrong... After I put your example with the book example I understand whats going on now.

    THANKS FOR YOUR HELP!
Sign In or Register to comment.