Adobe InDesign CS5 (7.0) Object Model JS: global

InDesign CS5

Class

global

 The global methods and properties for ExtendScript.

QuickLinks

alert, confirm, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent, escape, eval, isFinite, isNaN, isXMLName, localize, parseFloat, parseInt, prompt, setDefaultXMLNamespace, unescape, uneval

Properties

PropertyTypeAccessDescription
Infinitynumber r/wThe Infinity global property is a predefined variable with the value for infinity. (default: +Infinity)
NaNnumber r/wThe NaN global property is a predefined variable with the value NaN (Not-a-Number), as specified by the IEEE-754 standard. (default: NaN)
undefinedUndefined r/wThis global property is a predefined variable with the value for an undefined value. (default: undefined)

Methods

Instances

void alert (message: string[, title: string][, errorIcon: bool=false])
Displays an alert box

ParameterTypeDescription
messagestringThe text to display
titlestringThe title of the alert; ignored on the Macintosh (Optional)
errorIconboolDisplay an Error icon; ignored on the Macintosh (default: false)

bool confirm (message: string[, noAsDefault: bool=false][, title: string])
Displays an alert box with Yes and No buttons; returns true for Yes

ParameterTypeDescription
messagestringThe text to display
noAsDefaultboolSet to true to set the No button as the default button (default: false)
titlestringThe title of the alert; ignored on the Macintosh (Optional)

string decodeURI (uri: string)
Decodes a string created with encodeURI().

ParameterTypeDescription
uristringThe text to decode.

string decodeURIComponent (uri: string)
Decodes a string created with encodeURIComponent().

ParameterTypeDescription
uristringThe text to decode.

string encodeURI (text: string)
Encodes a string after RFC2396.
Create an UTF-8 ASCII encoded version of this string. The string is converted into UTF-8. Every non-alphanumeric character is encoded as a percent escape character of the form %xx, where xx is the hex value of the character. After the conversion to UTF-8 encoding and escaping, it is guaranteed that the string does not contain characters codes greater than 127. The list of characters not to be encoded is -_.!~*'();/?:@&=+$,#. The method returns false on errors.

ParameterTypeDescription
textstringThe text to encode.

string encodeURIComponent (text: string)
Encodes a string after RFC2396.
Create an UTF-8 ASCII encoded version of this string. The string is converted into UTF-8. Every non-alphanumeric character is encoded as a percent escape character of the form %xx, where xx is the hex value of the character. After the conversion to UTF-8 encoding and escaping, it is guaranteed that the string does not contain characters codes greater than 127. The list of characters not to be encoded is -_.!~*'(). The method returns false on errors.

ParameterTypeDescription
textstringThe text to encode.

string escape (aString: string)
Creates a URL-encoded string from aString.
In the new string, characters of aString that require URL encoding are replaced with the format %xx, where xx is the hexadecimal value of the character code in the Unicode character set. This format is used to transmit information appended to a URL during, for example, execution of the GET method. Use the unescape() global function to translate the string back into its original format. Returns a string which is aString URL-encoded.

ParameterTypeDescription
aStringstringThe string to be encoded.

Exampleescape(aString)

any eval (stringExpression: string)
Evaluates its argument as a JavaScript script, and returns the result of evaluation.
You can pass the result of an object's toSource() method to reconstruct that object.

ParameterTypeDescription
stringExpressionstringThe string to evaluate.

Exampleeval(stringExpression)

bool isFinite (expression: number)
Evaluates an expression and reports whether the result is a finite number.
Returns true if the expression is a finite number, false otherwise. False if the value is infinity or negative infinity.

ParameterTypeDescription
expressionnumberAny valid JavaScript expression.

ExampleisFinite(expression)

bool isNaN (expression: number)
Evaluates an expression and reports whether the result is "Not-a-Number" (NaN).
Returns true if the result of evaluation is not a number (NaN), false if the value is a number.

ParameterTypeDescription
expressionnumberAny valid JavaScript expression.

ExampleisNaN(expression)

bool isXMLName (name: string)
Returns true if the supplied string is a valid XML name.

ParameterTypeDescription
namestringThe XML name to test.

string localize (what: string[, argument: any])
Localizes a ZString-encoded string and merges additional arguments into the string.

ParameterTypeDescription
whatstringThe string to localize. A ZString-encoded string that can contain placeholder for additional arguments in the form %1 to %n.
argument any Optional argument(s) to be merged into the string. There may be more than one argument. (Optional)

number parseFloat (text: string)
Extracts a floating-point number from a string.
Parses a string to find the first set of characters that can be converted to a floating point number, and returns that number, or NaN if it does not encounter characters that it can converted to a number. The function supports exponential notation.

ParameterTypeDescription
textstringThe string from which to extract a floating point number.

ExampleparseFloat(aString)

number parseInt (text: string[, base: number])
Extracts an integer from a string.
Parses a string to find the first set of characters, in a specified base, that can be converted to an integer, and returns that integer, or NaN if it does not encounter characters that it can convert to a number.

ParameterTypeDescription
textstringThe string from which to extract an integer.
basenumber (range: 2 - 36)The base of the string to parse (from base 2 to base 36).
If not supplied, base is determined by the format of string. (Optional)

ExampleparseInt(aString, base)

string prompt (prompt: string[, default: string][, title: string])
Displays a dialog allowing the user to enter text
Returns null if the user cancelled the dialog, the text otherwise

ParameterTypeDescription
promptstringThe text to display
defaultstringThe default text to preset the edit field with (Optional)
titlestringThe title of the dialog; (Optional)

void setDefaultXMLNamespace (namespace: Namespace)
Defines the default XML namespace.
This is a replacement function for the standard JavaScript statement set default xml namespace.

ParameterTypeDescription
namespaceNamespaceThe namespace to use.
Omit this parameter to return to the empty namespace. This is either a Namespace object or a string.

string unescape (stringExpression: string)
Translates URL-encoded string into a regular string, and returns that string.
Use the escape() global function to URL-encode strings.

ParameterTypeDescription
stringExpressionstringThe URL-encoded string to convert.

Exampleunescape(stringExpression)

string uneval (what: any)
Creates a source code representation of the supplied argument, and returns it as a string.

ParameterTypeDescription
what any The object to uneval.

Jongware, 20-Jun-2010 v3.0.3dContents :: Index