Removing carriage returns from a long string

patcc

Well Known Member
Hi,

I have a very long string and I would like to remove any return carriage at the end of the string.

I have seen the BSFN B1702080 but it can only accept 80 characters long and mine is 256 chars long. I know I can split it into 2 strings and truncate the last part.

But I was wondering if there is any easier way to remove carriage return from a long string?

Thanks
 
You could do it in NER if you wanted to:

Last2Chars = substr(LongString, length(LongString)-2, 2)
if Last2Chars = "\r\l" then
LongString = substr(LongString, 1, length(LongString))
end if

or something along those lines. You have to be inside an NER function to use "\r\l", but you could write a function to return that for you. And you may want to do that anyway if you have an AS/400 to concern yourself with on account of the conversion to EBCDIC.

Also, in NER it's not flexible or useful for much else, but you get the point.

As for me, because of everything I just said, I would just write a custom C function. That would probably be best and flexiblest and easiest too.
 
Back
Top