Adobe 65024872 - InDesign CS4 - Mac Manual page 12

Scripting guide
Hide thumbs Also See for 65024872 - InDesign CS4 - Mac:
Table of Contents

Advertisement

Adobe InDesign CS4 Scripting Tutorial
Value type
Boolean
Integer
Double (VBScript),
fixed or real
(AppleScript),
floating point
(JavaScript)
String
Array (VBScript,
JavaScript)
or list (AppleScript)
Converting values from one type to another
All scripting languages supported by InDesign provide ways to convert variable values from one type to
another. The most common conversions involve converting numbers to strings (so you can enter them in
text or display them in dialog boxes) or converting strings to numbers (so you can use them to set a point
size or page location). See the examples below.
Apple-
--To convert from a number to a string:
Script
set myNumber to 2
set myString to (myNumber as string)
--To convert from a string to a number:
set myString to "2"
set myNumber to (myString as integer)
--if your string contains a decimal value, use "as real" rather than "as integer"
JavaScript
//To convert from a number to a string:
myNumber = 2;
myString = myNumber + "";
//To convert from a string to an integer:
myString = "2";
myNumber = parseInt(myString);
//If your string contains a decimal value, use "parseFloat" rather than "parseInt":
myNumber = parseFloat(myString);
//You can also convert strings to numbers using the following:
myNumber = +myString;
What it is
Logical True or False.
Whole numbers (no decimal
points). Integers can be positive
or negative. In VBScript, you can
use the long data type for
integers. In AppleScript, you
also can use the fixed or long
data types for both integers and
real numbers.
A high-precision number that
can contain a decimal point.
A series of text characters.
Strings appear inside (straight)
quotation marks.
A list of values (the values can
be any type).
Scripting and the InDesign object model 12
Example
True
14
13.9972
"I am a string"
AppleScript:
{"0p0", "0p0", "16p4", "20p6"}
VBScript:
Array("0p0", "0p0", "16p4", "20p6")
JavaScript:
["0p0", "0p0", "16p4", "20p6"]

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs4

Table of Contents