Adobe 27510753 Scripting Guide - Page 77
Modular programming support, Preprocessor directives
UPC - 718659445294
View all Adobe 27510753 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 77 highlights
Adobe InDesign CS2 Scripting Guide Using ExtendScript Tools and Features 69 If one operand is unitValue object and the other is a number, the operation is applied to the number and the numeric value of the object. The expression returns a new unitValue object with the result as its value. For example: val = new UnitValue ("10 cm"); res = val * 20; // res is a UnitValue (200, "cm"); If both operands are unitValue objects, JavaScript converts the right operand to the same unit as the left operand and applies the operation to the resulting values. The expression returns a new unitValue object with the unit of the left operand, and the result value. For example: a = new UnitValue ("1 m"); b = new UnitValue ("10 cm"); a + b; // res is a UnitValue (1.1, "m"); b + a; // res is a UnitValue (110, "cm"); l Comparisons If one operand is a unitValue object and the other is a number, JavaScript compares the number with the unitValue's numeric value. If both operands are unitValue objects, JavaScript converts both objects to the same unit, and compares the converted numeric values. For example: a = new UnitValue ("98 cm"); b = new UnitValue ("1 m"); a < b; // => true a < 1; // => false a == 98; // => true Modular programming support ExtendScript provides support for a modular approach to scripting by allowing you to include one script in another as a resource, and allowing a script to export definitions that can be imported and used in another script. Preprocessor directives ExtendScript provides preprocessor directives for including external scripts, naming scripts, specifying an ExtendScript engine, and setting certain flags. You can specify these in two ways: l With a C-style statement starting with the # character: #include "file.jsxinc" l In a comment whose text starts with the @ character: // @include "file.jsxinc" When a directive takes one or more arguments, and an argument contains any nonalphanumeric characters, the argument must be enclosed in single or double quotes. This is generally the case with paths and file names, for example, which contain dots and slashes.