I am trying to find a clean and simple way to manipulate a string.
I am sending an HL7 result message that contains a comment section.
In this comment section I am inserting my comment (var = cComment)
cComment can contain a paragraph or more.
The issue I'm having is, if the user enters their comment as one long string (ie: no CRLFs) the comment gets cut off.
If I add the "~" character to the HL7 message, it tells the system to add a CRLF.
So, the max length of the text before it gets cut off is 126 characters per line.
Now, the issue becomes, I can't just insert the "~" character every 126 characters because I do not want to start a new line in the middle of a word.
I need a way to look at the string, and if there is something other than a space where I need to insert the "~", move back until a space is found then insert the character and move to the next 126 character.
Any ideas?