Jump to content

More than one Space between in adressinformation - Business card


marcusm

Recommended Posts

Hi,

 

I have a problem with a Business Card.

 

The customer wants to fill in an address on their business card with about two-three Spaces between each "addressword".

 

See example below:

 

Streetname 10 Box 500 451 25 Townsfield

 

If the customer fills the text above in our DSF the spaces will be trimmed and only on space will seperate the words.

 

I have tried to get each variable on the addressline to one variable like this in FusionPro:

 

 

<Address> <Box> <Postnumber> <Town>

 

But when I fill in Supress if containing empty variables on for an example <Box> the whole line of variables will disappear.

 

I have also tried Supress if empty on a single variable <Box>, but then the spaces will remain and the Business card fails to format as I want.

 

Is there any solution to this problem? Is there any tag to get more space between words in a variable? Word-spacing in FusionPro don't work as I want.

 

 

I tried this rule:

 

if (Field("Box") == String(" "))

{

return "<span>" + Field("Adress") + (" ") + (" ") + Field("Postnummer") + (" ") + (" ") + Field("Ort") + (" ") + (" ") + Field("Land") + "</span>";

}

else

{

return "<span>" + Field("Adress") + (" ") + (" ") + Field("Box") + (" ") + (" ") + Field("Postnummer") + (" ") + (" ") + Field("Ort") + (" ") + (" ") + Field("Land") + "</span>";

}

return "";

 

 

But the spaces don't show up in Preview, only when I test the code. Why does it trim spaces automatically?

Link to comment
Share on other sites

Marcusm, try adding each element at a time if and only if it is valid...

var stringOut = ""
if (Trim(Field("Address")) !=  "")
   stringOut += Trim(Field("Address"));

if (Trim(Field("Box")) !=  "")  {
    if (stringOut != "")  {
         stringOut += "  " + Trim(Field("Box"));
    }
    else  {
         stringOut += Trim(Field("Box"));
    }
}

if (Trim(Field("Postnumber")) !=  "")  {
    if (stringOut != "")  {
         stringOut += "  " + Trim(Field("Postnumber"));
    }
    else  {
         stringOut += Trim(Field("Postnumber"));
    }
}

if (Trim(Field("Town")) !=  "")  {
    if (stringOut != "")  {
         stringOut += "  " + Trim(Field("Town"));
    }
    else  {
         stringOut += Trim(Field("Town"));
    }
}

return stringOut;

This should return a string that contains only those elements that are valid or non-blank with two spaces between each item. You could also try using non-breaking spaces " " in your code instead of just a normal space. Just be sure to turn on the tagged text check box if you do. Now you can just have a paragraph entry of only removing the line if the "entire line" is blank (which will occur if all elements are blank) and not just if one element contains a blank entry.

 

This may be a sledge-hammer way of doing it and you might be able to write a global function in place of the bottom three "if..then" statements but this way shows the overall logic of what I'm saying.

 

Good Luck

.

Link to comment
Share on other sites

I manage to solve the problem with this code for the Box field.

 

if (Field("Box") == "")

return (" ") + (" ");

else

return (" ") + (" ") + Field("Box") + (" ") + (" ");

 

 

I realize now afterwards that returning Field("Box") won't add something :o

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...