It sounds like you're trying to do a kind of poor-man's copyfitting by
counting characters.  That's at best a rough approximation.  Most
business card jobs I've seen simply use the CopyfitLine function, or a
variation thereof, to make the text fit.

However, if you really want to break the line instead of varying the
attributes of the text to make it fit, I would measure the actual extent
of the text, not the number of characters, to see if it fits on a
certain number of lines or not.  For instance:

    var textContent1 = Field("FName") + " " +
        Field("MInitial") + " " + Field("LName") +
        ", " + Field("Designations");
    var textContent2 = Field("FName") + " " +
        Field("MInitial") + " " + Field("LName") +
        "<br>" + Field("Designations");

    var tm = new FusionProTextMeasure;
    tm.useTags = false;

    // Change these properties to match
    // the font and point size of the text,
    // as well as the width of your frame.
    tm.font = "Arial";
    tm.pointSize = "12 pt";
    tm.maxWidth = "3 in";

    if (tm.CalculateTextExtent(textContent1) != 0)
      ReportError("Text measurement error: " + tm.messages);

    if (tm.textLines < 2)
      return textContent1;
    //else
    return textContent2;

Note that I didn't include the textContent3 case, as that's basically
the same as the first case.  There's no need to explicitly replace a
space with a line break; if the text doesn't fit on one line, it will
wrap automatically at the nearest space, like it always does.  Of
course, I'm also not exactly sure why you don't want to have the comma
in there just because the text might be wrapping, but it's your job.

Also, regarding David's remark that "if there is no middle initial, it
will print a double space," that's actually not true.  If you have the
"Treat returned strings as tagged text" box checked, then multiple
spaces will be collapsed by the tagged markup parser.  The real problem
here is the same one you alluded to earlier, which is that the number of
characters you're counting, including the markup tags and whitespace,
does not necessarily correlate to the number of characters which will be
output, nor to the amount of actual space which they will take up.

Dan


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
FusionPro 5.0 Now Available!


Variable text on a curve and soft drop-shadows for variable text


LIMITED TIME upgrade offer of $299 per license for current customers:
http://fusionpro.printable.com/store/upgrade

New licenses available for $599 each at:
http://fusionpro.printable.com/store/

All FusionPro 5.0 customers to receive FusionPro 5.1 with
Adobe Acrobat 8 and InDesign CS3 support when released for FREE.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
--
Users of FusionPro Desktop have unlimited free email support. Contact Printable 
Support at [EMAIL PROTECTED]
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm

--
You are currently subscribed to fusionpro as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--


--
Note:  All e-mail sent to or from this address will be received or otherwise 
recorded by the e-mail recipients of this forum. It is subject to archival, 
monitoring or review by, and/or disclosure to someone other than the recipient. 
Our privacy policy is posted on www.printplanet.com
--

Reply via email to