Jump to content

Can a rule be created to prevent a Canada zip code from breaking?


maryj

Recommended Posts

Sure, create a blank text rule and paste this into it:

 

var zip = [color="Red"]Field("YOURZIPFIELD")[/color];
return zip.replace(" "," ");

 

Remember to check the box beside "Treat returned strings as tagged text" and replace the field in red with the name of your zip code field.

Link to comment
Share on other sites

Yes, that does look like what I am looking for, but I don't understand the code. It looks to me like it will create a text resource, is that correct? I tried using it and replacing it like this, but it didn't print anything, can you tell me what I am doing wrong? Here is what I used:

 

var name = CreateResource("Dealer\\" + Field("Dealer_Name") + ".txt", "tagged text file", true);

return name.content.replace(/(.*)(\s)(.+)$/, "$1 $3");

Link to comment
Share on other sites

Try this:

 

// Use TextMeasure to get the length of each company name
var tm = new FusionProTextMeasure;
var frameWidth = [color="red"]2[/color]; // set width of the text box (in inches)
tm.pointSize = "[color="red"]10 pt[/color]"; // set the type size
tm.font = "[color="red"]Helvetica[/color]"; // set your typeface
var str = Field("[color="Red"]YOURFIELDNAMEHERE[/color]"); // set the field to use
tm.CalculateTextExtent(str);
tm.useTags = false;
var tmWidth = tm.textWidth;

return (tmWidth < frameWidth*7200) ? str : str.replace(/(.*)(\s)(.+)$/, "$1 $3");

 

Edit all of the places in red to match your job and this should give you your desired results.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...