maryj Posted December 30, 2011 Share Posted December 30, 2011 Is it possible for a rule to be created that will prevent a Canada zip code from breaking? Link to comment Share on other sites More sharing options...
step Posted December 30, 2011 Share Posted December 30, 2011 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 More sharing options...
maryj Posted December 30, 2011 Author Share Posted December 30, 2011 Thanks, that worked great! Another question - Can you create a rule that if a company name runs to 2 lines, that the second line will have at least 2 words on it? Thanks again! Link to comment Share on other sites More sharing options...
step Posted January 3, 2012 Share Posted January 3, 2012 Sounds like you're looking for something like this. Link to comment Share on other sites More sharing options...
maryj Posted January 3, 2012 Author Share Posted January 3, 2012 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 More sharing options...
step Posted January 3, 2012 Share Posted January 3, 2012 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 More sharing options...
maryj Posted January 3, 2012 Author Share Posted January 3, 2012 Thank you very much, that worked GREAT!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.