Instead of this:

  return '<color cmyk=ctotal>' + "g" + '</color>';

You need to do something like this:

  return '<color cmyk=' + ctotal + '>g</color>';

You were returning the name of the variable as part of a literal string,
rather than using the variable's value.  This should have been fairly
obvious from clicking "Validate".

Also, there's a much simpler way to get hex values; it's built into
JavaScript:

  return N.toString(16);

<http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Glob
al_Objects:Number:toString>

You can use ToUpper or String.toUpperCase if you want the letters
capitalized.

If you want to also make sure you pad out to a certain number of hex
digits, you can make a function to do something like this:

  function toHex(N, places)
  {
    var hex = Int(N).toString(16);
    if (!places)
      return hex;

    return Right(new Array(places+1).join("0") + hex, places);
  }

For the "cmyk" value of the color tag, you need to pad each value to two
hex digits, which I would do in another function, like so:

  function PercentTo2DigitHex(num)
  {
    return toHex(Round(Number(num)*2.55,0), 2);
  }

And then the rest of the rule would be like so:

  var c1 = PercentTo2DigitHex(Field("C"));
  var c2 = PercentTo2DigitHex(Field("M"));
  var c3 = PercentTo2DigitHex(Field("Y"));
  var c4 = PercentTo2DigitHex(Field("K"));
 
  var ctotal = c1+c2+c3+c4;
  //returns a "g" - when grow to fit enabled with webdings creates a box
  return '<color cmyk=' + ctotal + '>g</color>';

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