0.010/29/2019

HOWTO-1235: Remove Empty Lines in Addresses

Description

How do I make sure that empty lines are removed in a text object such as an address with optional information?

Contents

In a variable contents text object such as an address, it may happen that you have an empty line. In an address block for example, the "Line 2" of an address can contain a suite or address but sometimes does not. Leaving that line empty is not recommended, especially when printing the address for shipping a letter or postcard.

Windows Method

When you create your address text object, you will most likely end up with something like this:

@FirstName@ @LastName@
@Address1@
@Address2@
@City@, @State@ @Zip@

In order for the second line to remove itself when it is empty, all you need to do is to go in the text box's properties and change the "Remove Empty Lines" option to "Yes". This way, when your @Address2@ field is empty, the third line (City, State Zip) will move up to fill it's place.

If you find that this does not work, it is most likely because the line isn't actually empty. First, make sure that you do not have a space before or after your @Address2@ variable. Then, make sure your [Address2] field in your database doesn't contain a space. If it does, you can simply modify the @Address2@ variable expression to remove it automatically:

TRIM([Address2])

This should work with any line with a single variable and no static text around it. In the even where you actually do have text around, for example if your address was split into an apartment "type" and "number", you would end up with two variables with a space, such as @AptType@ @AptNumber@. In this case, the space between the variables means the line will never be empty. To resolve this, you would need to add the space conditionally, directly within the variable. You first stick the variables together, @AptType@@AptNumber , then you edit the first variable to add the space if the field is not empty:

IF(LENGTH(TRIM([AptType])) > 0, TRIM([AptType]) & " ", "")

This expression checks if the AptType field has one or more characters in it (after trimming spaces) and, if it is, outputs the database field along with a space after it.

Macintosh Method

Because PrintShop Mail ME does not have a "Remove Empty Lines" feature for the text object itself (it only works within variables), you'll need to put all your database fields within the same variable in order for this trick to work.

Here is how to do it:

  1. Add a text box to your page.
  2. In this text box, type in @addressblock@
  3. Click outside the text box.
  4. Go to Window>Object Variables
  5. Double-click on addressblock
  6. Create your text box expression. Here is a typical address block expression:
    • [Name] & "¶" & [Address1] & "¶" & [Address2] & "¶" & [City] & ", " & [State] & " " & [ZIP]
      ( "¶" = "hard carriage return" )
  7. Click on Verify to confirm the formula is correct.
  8. Click OK.
  9. Unselect the text box by clicking anywhere else on the document.
  10. Point to text box & right click.
  11. Click on Properties>Text Properties> uncheck Allow Empty Lines (this will top align text).
  12. Click OK.

Of course, the expression described in point 6 can be modified to you need. Also, the expression at the end of the Windows Method section can be adapter in the same way within this expression if necessary.