Adding control codes to a string

An area to discuss 8-bit PIC specific problems and examples

Moderator: Benj

Post Reply
crispin12
Posts: 51
Joined: Fri Apr 07, 2017 5:51 pm
Has thanked: 6 times
Been thanked: 11 times
Contact:

Adding control codes to a string

Post by crispin12 »

I've inserted a UART component macro into my program that is Send String. In the macro properties window I have the Name - Data, Type <- STRING, and Expression "This is a string"
How do you add the control codes for end of string and line feed?
In the expression box do I type "This is a string \0\r\n"
I thought the control codes had to be outside the "...." but when trying to add them outside the " " I receive an invalid expression when I attempt to save and close the component macro.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Adding control codes to a string

Post by kersing »

Control codes like \n and \r need to be inside the quotes. Adding \0 will terminate the string at that point, any characters beyond will be ignored, so avoid adding it before other control characters.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply