Adobe 27510753 Scripting Guide - Page 17

Values and variables, Values, AppleScript, VBScript

Page 17 highlights

Adobe InDesign CS2 Scripting Guide Scripting Basics 9 AppleScript first text frame of the first spread of the first document Note: When your AppleScript refers to a text object, InDesign returns the text contained in the object-not a reference to the object itself. To get a reference to the text object, use the object reference property, as shown in this example: tell application "Adobe InDesign CS2" set myDocument to make document tell spread 1 of myDocument set myTextFrame to make text frame set contents of myTextFrame to "InDesign" --The following line returns the text "InDesign" get paragraph 1 of myTextFrame --The following line returns a text object get object reference of paragraph 1 of myTextFrame end tell end tell VBScript Documents.Item(1).Spreads.Item(1).TextFrames.Item(1) JavaScript app.documents.item(0).spreads.item(0).textFrames.item(0) Values and variables Scripts become particularly useful when you can specify exact data (values) and use variables (containers for data). Values The point size of a character of text, the horizontal location of a text frame on a page, or the color of stroke of a rectangle are all examples of values used in InDesign scripting. Values are the data that your scripts use to do their work. The type of a value defines what sort of data the value contains. The value type of the contents of a word, for example, is a text string; the value type of the leading of a paragraph is a number. Usually, the values used in scripts are numbers or text. The following table explains the value types most commonly used in InDesign scripting. Value type Boolean Integer What it is Example Logical True or False True Whole numbers (no decimal points). 14 Integers can be positive or negative. In VBScript, you can use the long data type for integers. In AppleScript, you can also use the fixed or long data types for both integers and real numbers.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

Adobe InDesign CS2 Scripting Guide
Scripting Basics
9
AppleScript
first text frame of the first spread of the first document
Note:
When your AppleScript refers to a text object, InDesign returns the text contained in the object—not a
reference to the object itself. To get a reference to the text object, use the object reference property, as
shown in this example:
tell application "Adobe InDesign CS2"
set myDocument to make document
tell spread 1 of myDocument
set myTextFrame to make text frame
set contents of myTextFrame to "InDesign"
--The following line returns the text "InDesign"
get paragraph 1 of myTextFrame
--The following line returns a text object
get object reference of paragraph 1 of myTextFrame
end tell
end tell
VBScript
Documents.Item(1).Spreads.Item(1).TextFrames.Item(1)
JavaScript
app.documents.item(0).spreads.item(0).textFrames.item(0)
Values and variables
Scripts become particularly useful when you can specify exact data (values) and use variables (containers for
data).
Values
The point size of a character of text, the horizontal location of a text frame on a page, or the color of stroke of
a rectangle are all examples of values used in InDesign scripting. Values are the data that your scripts use to
do their work.
The
type
of a value defines what sort of data the value contains. The value type of the contents of a word, for
example, is a text string; the value type of the leading of a paragraph is a number. Usually, the values
used
in scripts are numbers or text. The following table explains the value types most commonly used in InDesign
scripting.
Value type
What it is
Example
Boolean
Logical True or False
True
Integer
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
can also use the fixed or long data types
for both integers and real numbers.
14