Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 31st, 2012, 08:17 AM
Steve Blatman Steve Blatman is offline
Junior Community Member
 
Join Date: Oct 2008
Location: Malvern, PA
Posts: 14
Default Need help to make field multi-line

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
Reply With Quote
  #2  
Old May 31st, 2012, 10:18 AM
sschardan sschardan is offline
Regular Contributor
 
Join Date: Oct 2008
Location: St. Louis, MO
Posts: 94
Default Re: Need help to make field multi-line

Steve,

If there are spaces separating the characters in the field, you could do something like this.

Code:
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.
Reply With Quote
  #3  
Old May 31st, 2012, 10:30 AM
sschardan sschardan is offline
Regular Contributor
 
Join Date: Oct 2008
Location: St. Louis, MO
Posts: 94
Default Re: Need help to make field multi-line

even simpler code

Code:
TypeSplit = Field("New Field").split(" ");


return TypeSplit[0] + '<br>' + TypeSplit[1] + '<br>' + TypeSplit[2]
Reply With Quote
  #4  
Old May 31st, 2012, 10:43 AM
Steve Blatman Steve Blatman is offline
Junior Community Member
 
Join Date: Oct 2008
Location: Malvern, PA
Posts: 14
Default Re: Need help to make field multi-line

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
Reply With Quote
  #5  
Old May 31st, 2012, 10:57 AM
sschardan sschardan is offline
Regular Contributor
 
Join Date: Oct 2008
Location: St. Louis, MO
Posts: 94
Default Re: Need help to make field multi-line

see if this works

Code:
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
Reply With Quote
  #6  
Old May 31st, 2012, 12:30 PM
Steve Blatman Steve Blatman is offline
Junior Community Member
 
Join Date: Oct 2008
Location: Malvern, PA
Posts: 14
Default Re: Need help to make field multi-line

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
Reply With Quote
  #7  
Old May 31st, 2012, 01:16 PM
Steve Blatman Steve Blatman is offline
Junior Community Member
 
Join Date: Oct 2008
Location: Malvern, PA
Posts: 14
Default Re: Need help to make field multi-line

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
Reply With Quote
  #8  
Old June 1st, 2012, 06:36 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Need help to make field multi-line

Quote:
Originally Posted by Steve Blatman View Post
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:
Code:
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 Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09

Last edited by esmith; June 1st, 2012 at 06:38 AM..
Reply With Quote
  #9  
Old June 1st, 2012, 07:12 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,478
Default Re: Need help to make field multi-line

Quote:
Originally Posted by esmith View Post
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:
Code:
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:
Code:
return TaggedFromRaw(Field("fieldname")).split("").join("<br>");
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.