Jump to content

commas and wrapping fileds


Recommended Posts

I am trying to fix two problems within one text frame so bear with me.


First problem I need commas only seperating populated fileds

these are all in a line like this on doc. but I want there only to be a comma after populated fields (ie add2 isn't always populated)

<comp> <add1> <add2> <csz> <phone>


the second thing I am trying to do here is if the line is two long to wrap down, but to not break the field when it wraps. currently I am getting some where half of the phone is on the top and half is on the bottom.


thanks, Jessica

Link to comment
Share on other sites

Try something like this (see the comments for what to customize for your job):

function AddFieldsToArray()
   var a = new Array;
   for (var i = 0; i < arguments.length; i++)
           if (Field(arguments[i]))
       catch (e)

   return a;

// Your field names go here:
var array = AddFieldsToArray("comp", "add1", "add2", "csz", "phone");

// If you're using FusionPro 6.0 or later, simply replace the frame name here.
// If you're using a version before 6.0, you'll need to hard-code the width instead.
var FrameWidthHundPts = FindTextFrame("MyFrameName").GetSettableTextWidth();

// Change this to the desired font and size.
var tags = '<f name="Arial"><z newsize=20>';

var TM = new FusionProTextMeasure;
TM.maxWidth = FrameWidthHundPts;
for (var fields = array.length; fields > 0; fields--)
   var line1 = tags + "\n" + NormalizeEntities(array.slice(0, fields).join(","));
   var line2 = NormalizeEntities(array.slice(fields).join(","));
   if (TM.messages)
       ReportError("Error measuring text: " + TM.messages);
   if (TM.textLines < 2)
       return line1 + (line2 ? ("\n<br>\n" + line2) : "");

ReportError("Can't fit any fields on the line!");

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...