Jump to content

Need help to make field multi-line


Steve Blatman

Recommended Posts

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

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

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

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

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

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.

Edited by esmith
Link to comment
Share on other sites

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...