Log In    |    Knowledge Base    |    4D Home
Tech Tip: Deleting blank lines in blocks of text
Published On: July 16, 1999

It is a common requirement when building blocks of text, such as addresses, to need to remove any blank lines that may occur. For example you may have three fields for each address, but most use only two. Printing the text, or copying it to the clipboard, with blank lines looks unprofessional.

There is a quick way to remove the blank lines, however many there are, by using 4D's Replace string and Position functions:

` Build the text string, call a function and pass the text to be cleaned as
` the first and only parameter.
` The function returns the same text with no blank lines.

Cut and Paste the following code example into your
own 4D project

$CRCR:=Char(Carriage return )+Char(Carriage return )
$TextToClean:=Replace string($TextToClean;$CRCR;Char(Carriage return ))
Until (Position($CRCR;$TextToClean)=0)