IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#20882 - 01/25/08 07:11 AM Adding an Address String from data
tim.ambler Offline
Junior Member

Registered: 01/25/08
Posts: 5
Hi, I need to add an address string to a document.

I have 8 lines of address that looks like this.

Name
Add1
Add2
Add3
Add4
Add5
Add6
Pcode

I need them to look like this.

Name, Add1, Add2, Add3, Add4, Add5, Add6, Pcode

I can easily do this in a text box, however I need the commas and spaces to dissapear if there is no data in the fields.

So if there was only 3 lines of address it wouldnt look like this.

Name, add1, , , , , , Pcode

It would look like this

Name, add1, Pcode

Does anyone know how I would make this work?

Thank you,

Tim

Top
#20883 - 01/25/08 08:18 AM Re: Adding an Address String from data
JAFrank Offline
OL User

Registered: 01/04/02
Posts: 86
Loc: Portland, OR
You could use a simple PressTalk within a Custom Data Selection to do this.

Add a Data Selection object to your form.
Go to the Data page in the dialog and select the Custom Data Selection check box
In the String to Display box, type the following:
Code:
=if(trim(@(1,1,25))='', '',trim)@(1,1,25))+',')
Here is what this does:

Remember that the syntax of the if() function is if(condition to test, value if true, value if false)
First, it tests a condition -
Code:
=if(trim(@(1,1,25))=''
This says "if we remove the extra spaces - trim() - from our data selection - @(1,1,25) - is it equal to an empty string - = ''?

If it is, then display an empty string -
Code:
''
If it is not, then display the data selection (with extra spaces trimmed off) followed by a comma -
Code:
@(1,1,25))+','
Once you get the first address to display properly, double click on the word 'true' in the CRLF column to toggle it to 'false', and then press Enter to add another data selection. you can now copy any paste your code from the first data selection - changing the line number as needed - @(2,1,25).

Repeat as many times as you like.

You could achieve the same result with a Text object by going to the Variables dialog and creating a variable for each address line, using the same technique.

Hope this is helpful to you

Good luck.

JAFrank

Top


Moderator:  cosimo, OL Newsgroup Support