Shop OBEX P1 Docs P2 Docs Learn Events
debug caracter (") in string — Parallax Forums

debug caracter (") in string

dardar Posts: 15
edited 2012-12-18 08:52 in Propeller 1
Hi again!:

I'm trying to write " like a caracter in a string, but when write it, it read that i close the string, for example:

I want to read in parallax serial terminal:

12345"

But if i do:

debug.str(string("12345""))

it considered that i'm starting a new string and don´t compile the code.

Can you help me??

Thanks

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2012-12-18 06:41
    I'm pretty sure you can embed the decimal value in the the string constant like this: debug.str(string("12345", 34))
  • dardar Posts: 15
    edited 2012-12-18 06:44
    thanks it works.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-18 08:35
    Martin already nailed it. Here's an example from code I'm currently working on.
    Pst.str(string(13, "Enter ", 34, "+", 34, " or ", 34, "*", 34)) 
            Pst.str(string(" to increase pulse length for center.")) 
            Pst.str(string(13, "Enter ", 34, "-", 34, " or ", 34, "/", 34)) 
            Pst.str(string(" to decrease pulse length for center.")) 
            Pst.str(string(13, "Enter any other key to adjust different servo."))
    

    The idea was to put quotes around "+", "*" and "-", "/".
  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-18 08:39
    Just as a style suggestion: Use a named constant for the quote. I use Quote in much of my code and I use names for other control codes as well, like CR. You'd have:

    CON Quote = 34

    and

    Pst.str(string(CR, "Enter ", Quote, "+", Quote, " or ", Quote, "*", Quote))
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-18 08:52
    Mike Green wrote: »
    Just as a style suggestion: Use a named constant for the quote. I use Quote in much of my code and I use names for other control codes as well, like CR. You'd have:

    CON Quote = 34

    and

    Pst.str(string(CR, "Enter ", Quote, "+", Quote, " or ", Quote, "*", Quote))

    I was about to say, the numbers are just as meaningful to me as "CR" or "Quote" and if the code is just for me it doesn't matter (but I'd reword it sounded better than the way that came out). But of course, I just posted it here, and a lot of code I write ends up on the forum so I decided to say the following instead.

    Good point. I agree. I think I'll start doing it the way you suggest.

    Thanks Mike.
Sign In or Register to comment.