Spaces between Variables

Posted by: KesslerCreative

Spaces between Variables - 09/25/09 02:52 PM

I am trying to figure out the best code to put a space between a prefix and a first name, if a prefix exists, and no space if a prefix does not exist.

My variables look like: @prefix@@firstname@@lastname@

If I put a space between @prefix@ and @firstname@ the address lines without a prefix look like they are indented, which the customer does not want.

I have tried using an IF expression to add a blank space but I can't get it to work right... any better ideas or suggestions?
Posted by: Anonymous

Re: Spaces between Variables - 09/25/09 03:02 PM

Hi,

You could do this by removing the @prefix@ variable and the space, and changing the @firstname@ variable expression to something like this:

IF(LEN([Prefix]) > 0, [Prefix] & " " & [FirstName], [FirstName])

Which basically translate as "if the length of the Prefix string is more than 0 (not empty), print the prefix, then a space, then the first name. Else, print just the firstname".

Hope this helps,
Eric.
Posted by: Wim

Re: Spaces between Variables - 10/22/09 06:33 AM

Hi,

You can use the trim command:

trim(trim(trim([prefix]) & " " & trim([firstname])) & " " & trim([lastname]))

Wim