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?
String manipulation
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
String manipulation
Thanks,
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: String manipulation
Code: Select all
function Convert( cStr )
local cOut := ""
local nAt
do while !Empty( cStr )
if Len( cStr ) <= 125
cOut += cStr
cStr := ""
else
nAt := RAT( " ", Left( cStr, 125 ) )
if nAt == 0
nAt := 125
endif
cOut += Left( cStr, nAt ) + "-"
cStr := SubStr( cStr, nAt + 1 )
endif
enddo
return cOut
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
-
- Posts: 988
- Joined: Thu Nov 24, 2005 3:01 pm
- Location: Madrid, España
Re: String manipulation
Hi Jeff,
have you tried the MemoLine() function + PadR()? I think it will do what you are looking for.
KR
Carlos
have you tried the MemoLine() function + PadR()? I think it will do what you are looking for.
KR
Carlos
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"