Linebreaks, cr(), lf() and linestrip(

A problem I continue to encounter and see from others too is dealing with line breaks and the various forms they take.

In trying to get large blocks of text to fit into a fixed space in a printed form I applied linestrip( to the text.

That lead me to discover that some records contained cr() and others contained lf() and that linestrip( handled only those with cr(). Those with lf() continued to have the unwanted breaks. I can correct that with lftocr( but I would expect that linestrip should handle it.

Ultimately what I’d like to accomplish is to reduce multiple line breaks to just one. Ins one places there may be two or three line breaks strung together. So currently I’m using:

Is there any equivalent to onewhitespace( for cr()'s?

linecount( predictably fails to see lf() too.

You could combine the linestrip( function with the replace( function to first convert any line feeds to carriage returns.


Ah, yes… I was into the weeds.

Please note that this code is EXACTLY the same as:


So that’s the optimum solution, but I have another tip that might be handy in the future. In Jim’s original formula, he used nested replace( functions. In Panorama X this is never needed, because a single replace( function can have multiple pairs of replace,with parameters, i.e.


This is a handy improvement in Panorama X that greatly cuts down on parentheses :grinning:

Not exactly. lftocr( also replaces crlf() with cr(), so there are two replacements in its formula, not just one.

You’re right (of course), but for his application it should be functionally the same I think.

After an offline discussion with Dave, I now realize that Gary’s solution would actually run slightly faster if the amount of text being handled was large (megabytes).

The text never exceeds more than 10,000 characters so MB isn’t a factor. Since I need to deal with it in a number of forms linestrip(lftocr(theText)) is slightly more convenient in applying.

The linestrip( function is now equivalent to arraystrip(thetext,cr()) but I think maybe it should be expanded to arraystrip(lftocr(thetext),cr()) so it handles lf and crlf line feed endings as well as carriage returns…

And I just made great use of it. I had seen it before but forgot about it. Not only does it reduce parentheses, it eliminates a string of replace(replace(replace(replace(replace( and the need to count them off to make sure you have the right number.

And yes, I know and use replacemultiple( , but strings of replace( always manage to work their way in.

Now that it allows multiple replaces in one function, I definitely prefer replace( over replacemultiple(. It’s just nicer to have each pair of this and that right next to each other. The only time I would continue to use replacemultiple( is if the before/after pairs are already in arrays for some reason.