Carriage Returns in Char field

Posted by Admin on 11-Apr-2011 14:54

Does anyone know of a way to strip carriage returns from a char field?  We have fields in our data base used for notes, and i need to output them to a file.  I need the notes to be on one line, though, and when I put stream the field it includes the carriage return.  I have ot use put stream instead of export because I have multiple output files generated in this report.  Anyone have any ideas?

All Replies

Posted by jmls on 11-Apr-2011 15:16

foo = REPLACE(foo,"~r","") /* strip cr */

foo = REPLACE(foo,"~n","") /* strip lf */

Julian

--

Julian Lyndon-Smith

IT Director, Dot R Limited

"I don’t care if it works on your machine!  We are not shipping your machine!”

Follow Dot R on http://twitter.com/DotRlimited

Posted by Admin on 12-Apr-2011 00:01

foo = REPLACE(foo,"~r","") /* strip cr */

foo = REPLACE(foo,"~n","") /* strip lf */

 

That will completely strip off the CR/LF.

If line by line processing is required we usually consider the text as being a CR delimited list:

DO i = 0 TO NUM-ENTRIES (foo, "~n"):

PUT UNFORMATTED ENTRY (I, foo, "~n") SKIP.

END.

Posted by jmls on 12-Apr-2011 00:31

That's right. If you use both lines The OP wanted to know

"Does anyone know of a way to strip carriage returns from a char field?"

yes - use example #1

This thread is closed