Is there a way to include the " character in a! string constant?

Flenser

Senior Member
Is there a way that the " character can be included in a string constant?
e.g. to send the string "Hello World!" including the double quotes.

In other languages there is a escape character that can be included in a string constant.
If the escape character was a backslash then the " character could be included in the string constant this way "\"Hello World!\""

Is there an equivalent escape character for picaxe string constants?
 

Aries

New Member
To include a special character (such as double-quote) in a Picaxe character string, use its ASCII value directly (double-quote is 34)

So:
Code:
sertxd(34,"Hello World",34)
will print
"Hello World"
 

inglewoodpete

Senior Member
To include a special character (such as double-quote) in a Picaxe character string, use its ASCII value directly (double-quote is 34)

So:
Code:
sertxd(34,"Hello World",34)
will print
"Hello World"
Alternatively, it can be stored in EEPROM and read back when required:
Rich (BB code):
EEPROM 0, (34, "Hello World", 34)
 

Flenser

Senior Member
Thanks to everyone for their replies.

The manual doesn't mention anything so I didn't think that there was any such escape character but I asked the question anyway in case there was some feature I wasn't aware of.
 

AllyCat

Senior Member
Hi,

The backslash (\) does appear to be a "partial" Escape character but not in a completely predictable manner. For example sertxd("\"Hello\"") works in the PE6 simulator and is accepted by {Win}Axepad (no simulator) but throws a syntax error in PE5. In PE5: sertxd("\"Hello\\") is accepted and prints something, but not what you want it to do - go figure. :(

Generally, it's much easier to just use the ASCII values from the Table under the Wizards or Help tabs.

Cheers, Alan.
 

hippy

Technical Support
Staff member
Using backslash escapes is one way, but I prefer SYMBOL defining the character -

Symbol DOUBLE_QUOTE = $22
SerTxd( DOUBLE_QUOTE, "Hello World!", DOUBLE_QUOTE)

You can of course name it however you want.
 

inglewoodpete

Senior Member
Using backslash escapes is one way, but I prefer SYMBOL defining the character -

Symbol DOUBLE_QUOTE = $22
SerTxd( DOUBLE_QUOTE, "Hello World!", DOUBLE_QUOTE)

You can of course name it however you want.
Similarly, I use D_Qot and S_Qot in PICAXE and MPLAB PIC C Programs
 
Top