jwhittaker Posted May 19, 2009 Share Posted May 19, 2009 This is a rule that will give me a 1 line address or a 2 line address. It's pretty basic. When I create the string "address" with spaces, it sees the spaces when calculating the length. I have treat returned strings as tagged text checked(for the <br>). When I validate to see the results I see the spaces, but when I preview the template there is only 1 space instead of 2 or 3 spaces. Where are they going? Anyone Know? Thanks Jon Whittaker OX 10.4.11 FP6.0P1b address = (Field("Address") + " " + Field("City") + ", " +Field("State") + " " + Field("Zip")); addressline1 = Field("Address"); addressline2 = (Field("City") + ", " +Field("State") + " " + Field("Zip")); if (address.length <= "45") { return address; } else { return (addressline1 + '<br>' + addressline2); } Link to comment Share on other sites More sharing options...
invaricconsulting Posted May 20, 2009 Share Posted May 20, 2009 when I preview the template there is only 1 space instead of 2 or 3 spaces Where specifically are you seeing the spaces missing? Between which fields? Link to comment Share on other sites More sharing options...
jwhittaker Posted May 20, 2009 Author Share Posted May 20, 2009 Sorry about that. I copied from my rule which shows the spaces and didn't check to see if it showed in this forum. There should be 3 spaces between the address and the city There should be a , and 1 space between the city and state There should be 2 spaces between the state and zip Link to comment Share on other sites More sharing options...
Dan Korn Posted May 20, 2009 Share Posted May 20, 2009 If you're returning tagged text, FusionPro's tagged markup parser collapses whitespace, and also processes ampersands and less-than symbols in the returned value as markup. So, whenever you have a rule that returns tags, you should wrap returned text retrieved from the Field function, or any string literals, in the TaggedTextFromRaw function (or NormalizeEntities in versions prior to 6.0, although that's not as sophisticated in dealing with whitespace). So you can add that call into your rule like so: address = Field("Add1") + " " + Field("City") + ", " +Field("State") + " " + Field("Zip"); addressline1 = Field("Add1"); addressline2 = Field("City") + ", " +Field("State") + " " + Field("Zip"); if (address.length <= 45) return TaggedTextFromRaw(address); //else return TaggedTextFromRaw(addressline1) + '<br>' + TaggedTextFromRaw(addressline2); You'll notice that I also changed the "if" statement logic to do a numeric comparison, instead of a string comparison. (In JavaScript, the string "2" is greater than the string "11".) Note also that by using [noparse][/noparse] markup in this forum, the whitespace in the rule itself is preserved. You can do this yourself by clicking "Go Advanced", then selecting the code in your post and clicking the # button. Finally, I should also mention that this kind of logic to determine whether a particular line of text will wrap can be accomplished more accurately with Text Measurement than by counting the number of characters. You may want to look at the CopyfitLine function. Link to comment Share on other sites More sharing options...
jwhittaker Posted May 20, 2009 Author Share Posted May 20, 2009 Thanks That worked! I still trying to figure out JS. I was just looking at the Tagged TextFromRaw. I will look into the copyfit function and see how I can get it to work. thanks again Jon Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.