Shop OBEX P1 Docs P2 Docs Learn Events
string delimiters — Parallax Forums

string delimiters

lfreezelfreeze Posts: 174
edited 2013-11-16 10:25 in Propeller 1
After a few days of trial and error, I still cannot solve this coding problem.
I am working with a sim900 cell phone module, I have had success with sending txt and email messages.
I want to add a function to read received txt messages. In order to do this I must send this command
To the sim900 module AT+CMGL="ALL" , the quotations marks are part of the command.
My problem is I cannot include the additional quotation marks in my string command.

phone.str(string("AT+CMGL=(“ALL”)", 13))

Are there any wildcard delimiters that I can use instead of the quote marks? Is there
Another way to do this?
Thanks….
Larry

Comments

  • Heater.Heater. Posts: 21,230
    edited 2013-11-16 09:42
    A double quote has a hexadecimal value of $22 or decimal 34 so you could send it as a byte of that value. Much as you do with that carriage return in your example.

    I can't remember if there is a way of escaping a quote, must be in the manual if there is.

    I'd be inclined to define the string in a DAT section. Something like:
    DAT
    myString BYTE "AT+CMGL=(“, $22, "ALL", $22, ")" , $0d, $00
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-16 10:02
    Just incase it's not clear from Heater's example, you can do the same thing inline.
    [COLOR=#333333]phone.str(string("AT+CMGL=(", 34, “ALL”, 34, ")", 13)) [/COLOR]
    

    I personally add (at Mike Green's suggestion) a constant declaration at the beginning of the program.
    CON
    
      QUOTE = 34
    

    So then the above code becomes:
    [COLOR=#333333]phone.str(string("AT+CMGL=(", [/COLOR]QUOTE[COLOR=#333333], “ALL”, [/COLOR]QUOTE[COLOR=#333333], ")", 13)) [/COLOR]
    

    I don't think there's a way use double quotes in Spin code other than referring to it by ASCII number.
  • lfreezelfreeze Posts: 174
    edited 2013-11-16 10:25
    Thank you for the responses, I will try them. I did check the propeller manual v1.0 and found a description of
    all the delimiters, but nothing for my situation

    Larry
Sign In or Register to comment.