Shop OBEX P1 Docs P2 Docs Learn Events
Why no early termination of Zstring when zero is in text? — Parallax Forums

Why no early termination of Zstring when zero is in text?

John KauffmanJohn Kauffman Posts: 653
edited 2010-11-12 19:31 in Propeller 1
In the following ZStrings, why is the string not considered terminated after the fifth character (the internal zero)?


text.str(string("The 0 come first"))

DAT
myString byte " The 0 come first ",0

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-11-12 17:09
    It's because it's an ASCII "0" which has the value $30, not $00.

    -Phil
  • John KauffmanJohn Kauffman Posts: 653
    edited 2010-11-12 17:53
    I'm half way understanding, just need to be sure....

    myString byte "The 0 come first ",0

    So in the above the zero at the end is being treated like a code (in the way of 13 for CR).

    Therefore:
    myString byte "The 0 come first 0"
    has not been terminated.

    Thanks.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-11-12 19:31
    That's correct.

    -Phil
Sign In or Register to comment.