Steve Blatman Posted May 31, 2012 Share Posted May 31, 2012 My customer's data has many 3-character fields, each of which I need to print as three characters stacked over one another. I tried just narrowing the text box so the field would wrap to three lines, but some of the characters, like "#", won't separate from the adjacent character--FP won't wrap between them. I need either javascript code to add carriage returns between the characters in a field, or some way of telling FP not to keep any pairs of characters together. (I'd prefer the former). The fields are always three characters, but the characters could be anything that prints (not just letters and numbers). TIA, Steve Link to comment Share on other sites More sharing options...
sschardan Posted May 31, 2012 Share Posted May 31, 2012 Steve, If there are spaces separating the characters in the field, you could do something like this. TypeSplit = Field("New Field").split(" "); TrimType1 = TypeSplit[0]; TrimType2 = TypeSplit[1]; TrimType3 = TypeSplit[2]; return TrimType1 + '<br>' + TrimType2 + '<br>' + TrimType3 Just be sure to replace my field with yours. Also, remember to check Treat returned strings as tagged text. Link to comment Share on other sites More sharing options...
sschardan Posted May 31, 2012 Share Posted May 31, 2012 even simpler code TypeSplit = Field("New Field").split(" "); return TypeSplit[0] + '<br>' + TypeSplit[1] + '<br>' + TypeSplit[2] Link to comment Share on other sites More sharing options...
Steve Blatman Posted May 31, 2012 Author Share Posted May 31, 2012 Unfortunately, there are NOT spaces between the characters--if there were, simply narrowing the column and forcing the text to wrap would have worked. I need to separate the three characters via Javascript. TIA, Steve Link to comment Share on other sites More sharing options...
sschardan Posted May 31, 2012 Share Posted May 31, 2012 see if this works Position1 = Left(Field("New Field"), 1); Position2a = Left(Field("New Field"), 2); Position2Final = Right(Position2a, 1); Position3 = Right(Field("New Field"), 1); return Position1 + '<br>' + Position2Final + '<br>' + Position3 Link to comment Share on other sites More sharing options...
Steve Blatman Posted May 31, 2012 Author Share Posted May 31, 2012 Thanks for your help--I have one more question.... I ended up with this: Position1 = Left(Field("fieldname"), 1; Position2 = Mid(Field("fieldname"), 2, 1; Position3 = Right(Field("fieldname"), 1; return Position1 + '<br>' + Position2 + '<br>' +Position3; However, if the character in Postion3 is an ampersand, I get a blank space in my output instead of the ampersand. Any idea why, and and suggestions for what to do about it? TIA, Steve Link to comment Share on other sites More sharing options...
Steve Blatman Posted May 31, 2012 Author Share Posted May 31, 2012 Never mind on that score -- adding one more ... + <'br'> at the end of the "return" line solves that one. When I compose, though, I get "incomplete entity definition" errors. The output, though, looks correct... I'm looking to see what that error is, but, if you know, it would save me some time. Thanks for your help today, Steve Link to comment Share on other sites More sharing options...
esmith Posted June 1, 2012 Share Posted June 1, 2012 When I compose, though, I get "incomplete entity definition" errors. The output, though, looks correct... I believe the "entity" error is a result of FP expecting the ampersand to be part of an HTML entity (tagged text). As an alternative option for your rule, you might want to try: var split = Field("fieldname").split(""); var result = split.join("\n"); return TaggedTextFromRaw(result);You'll need to check the "Treat returned strings as tagged text" box in the rule. Link to comment Share on other sites More sharing options...
Dan Korn Posted June 1, 2012 Share Posted June 1, 2012 I believe the "entity" error is a result of FP expecting the ampersand to be part of an HTML entity (tagged text). As an alternative option for your rule, you might want to try: var split = Field("fieldname").split(""); var result = split.join("\n"); return TaggedTextFromRaw(result);You'll need to check the "Treat returned strings as tagged text" box in the rule. Eric is correct: When you return tagged text, you need to make sure to call TaggedFromRaw on any data fields to make sure that special markup characters such as ampersands are escaped correctly for the tagged markup parser. However, Eric's solution is flawed, because you do still need the <br> tags to separate the letters onto multiple lines. This should do what you want: return TaggedFromRaw(Field("fieldname")).split("").join("<br>"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.