Adobe 27510753 Scripting Guide - Page 11

Copying examples with long lines, Running JavaScript files, Where to find more information

Page 11 highlights

Adobe InDesign CS2 Scripting Guide Introduction 3 3. Display the Scripts palette by choosing Window > Automation > Scripts. 4. Run the script by double-clicking the script name in the Scripts palette. Copying examples with long lines Because of the layout of this document and the nature of the copy and paste process, some long lines of code might include unwanted line breaks when you paste them into your script editor. In some cases, these line breaks will cause the script to fail. To fix the script, you must remove the unnecessary line breaks. Tip: In general, when you compile the script in AppleScript or full Visual Basic, your script editor tells you which lines you need to fix. AppleScript example When you paste the following line into a text editor, remove the line break following "properties". If you don't, the script generates an error. set myBaseNameField to make text editbox with properties {edit contents:myDocumentName, min width:160} JavaScript example When you paste the following line into a text editor, remove the line breaks following the commas-the line should end with the semicolon (";"). In this example it works correctly with or without line breaks; however, the ExtendScript interpreter can interpret a line break as the end of a statement in some cases. guides.add(myDocument.layers.item("GuideLayer"), {orientation:HorizontalOrVertical.horizontal, location:marginPreferences.top, fitToPage:false}); VBScript example When you paste the following line into a text editor, remove the line breaks preceding the equal sign (=). If you don't, the script generates an error. myInDesign.ActiveDocument.MasterSpreads.Item("B-Master").Pages.Item(1).AppliedMaster = myInDesign.ActiveDocument.MasterSpreads.Item("A-Master") Running JavaScript files Give InDesign JavaScript files the extension .jsx. You can run these files either from the ExtendScript Toolkit or from the Scripts palette, which guarantees that they are interpreted by the ExtendScript interpreter. You can also double-click them from your operating system to start the ExtendScript Toolkit and run the script. Where to find more information The Adobe InDesign CS2 Scripting Reference provides details about the objects, properties, and methods available for scripting in InDesign. We cannot fully document AppleScript, VBScript, or JavaScript, so you'll probably also need documentation for any or all of those scripting languages.

  • 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
Introduction
3
3.
Display the Scripts palette by choosing Window > Automation > Scripts.
4.
Run the script by double-clicking the script name in the Scripts palette.
Copying examples with long lines
Because of the layout of this document and the nature of the copy and paste process, some long lines of code
might include unwanted line breaks when you paste them into your script editor. In some cases, these line
breaks will cause the script to fail. To fix the script, you must remove the unnecessary line breaks.
Tip:
In general, when you compile the script in AppleScript or full Visual Basic, your script editor tells you
which lines you need to fix.
AppleScript example
When you paste the following line into a text editor, remove the line break following “properties”. If you don’t,
the script generates an error.
set myBaseNameField to make text editbox with properties
{edit contents:myDocumentName, min width:160}
JavaScript example
When you paste the following line into a text editor, remove the line breaks following the commas—the line
should end with the semicolon (“;”). In this example it works correctly with or without line breaks; however,
the ExtendScript interpreter can interpret a line break as the end of a statement in some cases.
guides.add(myDocument.layers.item("GuideLayer"),
{orientation:HorizontalOrVertical.horizontal, location:marginPreferences.top,
fitToPage:false});
VBScript example
When you paste the following line into a text editor, remove the line breaks preceding the equal sign (=). If
you don't, the script generates an error.
myInDesign.ActiveDocument.MasterSpreads.Item("B-Master").Pages.Item(1).AppliedMaster
= myInDesign.ActiveDocument.MasterSpreads.Item("A-Master")
Running JavaScript files
Give InDesign JavaScript files the extension
.jsx
. You can run these files either from the ExtendScript Toolkit
or from the Scripts palette, which guarantees that they are interpreted by the ExtendScript interpreter. You
can also double-click them from your operating system to start the ExtendScript Toolkit and run the script.
Where to find more information
The
Adobe InDesign CS2 Scripting Reference
provides details about the objects, properties, and methods
available for scripting in InDesign.
We cannot fully document AppleScript, VBScript, or JavaScript, so you’ll probably also need documentation
for any or all of those scripting languages.