Sending String with inverted commas as part of it

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

User avatar
jollybv
Flowcode v5 User
Posts: 342
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 77 times
Been thanked: 24 times
Contact:

Sending String with inverted commas as part of it

Postby jollybv » Tue Aug 27, 2019 3:19 pm

Hi Guys

How would I send a string like this AT+CSCS="GSM" with the inverted commas included

I have tried
String = "AT+CSCS="
String = String + ""GSM""

But this formula is not right

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4145 times
Contact:

Re: Sending String with inverted commas as part of it

Postby Benj » Tue Aug 27, 2019 5:15 pm

Hello,

This is the way I might do it.

"AT+CSCS=\"GSM\""

The slashes in front of the speech mark allows it to be escaped.
https://en.wikipedia.org/wiki/Escape_sequences_in_C
These users thanked the author Benj for the post:
jollybv (Wed Aug 28, 2019 7:26 am)
Rating: 5.26%
 

User avatar
jollybv
Flowcode v5 User
Posts: 342
Joined: Thu Feb 12, 2009 5:20 am
Has thanked: 77 times
Been thanked: 24 times
Contact:

Re: Sending String with inverted commas as part of it

Postby jollybv » Wed Aug 28, 2019 7:26 am

Hi Ben

Thanks for the reply i managed to sort it looking back at some old code
send = "AT+CSCS="
send = send + "\""
send = send + "GSM"
send = send + "\""

But I will use your code as it is way less code
These users thanked the author jollybv for the post:
Benj (Wed Aug 28, 2019 3:39 pm)
Rating: 5.26%