This book is an essential reference for anyone using AppleScript to modify existing scripts or write new ones. It provides many sample scripts and discusses advanced topics such as writing command handlers for script applications, the scope of script variables and properties declared at different levels in a script, and inheritance and delegation among script objects.
Author(s): Apple Computer Inc
Series: ATL
Edition: 1st edition
Publisher: Addison Wesley Longman
Year: 1994
Language: English
Pages: 415
AppleScript Language Guide......Page 1
Contents......Page 3
Figures and Tables......Page 13
Introduction......Page 17
Overview of AppleScript......Page 19
Conventions Used in This Guide......Page 20
What Is AppleScript?......Page 21
Who Runs Scripts and Who Writes Them?......Page 23
What Applications Are Scriptable?......Page 24
Automating Activities......Page 25
Integrating Applications......Page 27
How AppleScript Works......Page 29
Statements......Page 31
Commands and Objects......Page 32
Dictionaries......Page 34
Values and Constants......Page 36
Expressions......Page 37
Variables......Page 38
Script Objects......Page 39
Dialects......Page 40
Continuation Characters......Page 41
Comments......Page 43
Identifiers......Page 44
Case Sensitivity......Page 45
Abbreviations......Page 46
Debugging Scripts......Page 47
Values and Constants......Page 51
Literal Expressions......Page 52
Properties......Page 53
Operators......Page 54
Coercions Supported......Page 55
Common Value Class Definitions......Page 56
Boolean......Page 58
Class......Page 59
Constant......Page 60
Data......Page 61
Date......Page 62
Integer......Page 66
List......Page 67
Number......Page 71
Real......Page 72
Record......Page 74
Reference......Page 77
String......Page 80
Styled Text......Page 84
Unicode Text and International Text......Page 87
Unit Type Value Classes......Page 91
AppleScript Unit Types by Category......Page 92
Working With Unit Type Value Classes......Page 93
Other Value Classes......Page 94
File Specification......Page 95
Styled Clipboard Text......Page 96
Coercing Values......Page 97
Constants......Page 100
Considering and Ignoring Attributes......Page 101
Date and Time Constants......Page 102
Miscellaneous Script Constants......Page 103
String Constants......Page 105
Version Constant......Page 106
Commands......Page 109
Application Commands......Page 110
Scripting Addition Commands......Page 112
Target......Page 113
User-Defined Commands......Page 114
Using Command Definitions......Page 115
Parameters......Page 116
Examples......Page 117
Coercion of Parameters......Page 118
Parameters That Specify Locations......Page 119
Raw Data in Parameters......Page 120
Viewing a Result in the Script Editor’s Result Window......Page 121
Using the Predefined Result Variable......Page 122
When a Dictionary Is Not Available......Page 123
Entering Script Information in Raw Format......Page 125
Command Definitions......Page 127
Close......Page 130
Copy......Page 132
Count......Page 134
Delete......Page 137
Duplicate......Page 138
Exists......Page 139
Get......Page 141
Launch......Page 143
Make......Page 146
Move......Page 148
Open......Page 149
Print......Page 150
Quit......Page 151
Reopen......Page 152
Run......Page 154
Save......Page 156
Set......Page 157
Objects and References......Page 161
Object Class Definitions......Page 162
Properties......Page 164
References......Page 165
Containers......Page 167
Complete and Partial References......Page 168
Reference Forms......Page 169
Arbitrary Element......Page 170
Every Element......Page 171
Filter......Page 173
ID......Page 174
Index......Page 177
Middle Element......Page 179
Name......Page 180
Property......Page 182
Range......Page 183
Relative......Page 185
Using the Filter Reference Form......Page 187
References to Files and Applications......Page 190
Specifying a File by Name or Pathname......Page 191
Specifying a File by Reference......Page 192
Differences Between Files and Aliases......Page 193
References to Applications......Page 194
References to Local Applications......Page 195
References to Remote Applications......Page 196
Expressions......Page 199
Variables......Page 200
Creating Variables......Page 201
Using Variables......Page 202
The A Reference To Operator......Page 203
Data Sharing......Page 206
Predefined Variables......Page 207
Defining Script Properties......Page 208
Using Script Properties......Page 209
AppleScript Properties......Page 210
Reference Expressions......Page 212
Operations......Page 213
Operators That Handle Operands of Various Classes......Page 220
Equal, Is Not Equal To......Page 221
Greater Than, Less Than......Page 224
Starts With, Ends With......Page 226
Contains, Is Contained By......Page 227
Concatenation......Page 229
Operator Precedence......Page 231
Date-Time Arithmetic......Page 233
Working With Dates at Century Boundaries......Page 235
Control Statements......Page 237
Characteristics of Control Statements......Page 238
Debugging Control Statements......Page 239
Tell Statements......Page 240
Nested Tell Statements......Page 241
Using it, me, and my in Tell Statements......Page 242
Tell (Simple Statement)......Page 243
Tell (Compound Statement)......Page 244
If Statements......Page 245
If (Compound Statement)......Page 248
Repeat Statements......Page 249
Repeat (forever)......Page 250
Repeat (number) Times......Page 251
Repeat While......Page 252
Repeat Until......Page 253
Repeat With (loopVariable) From (startValue) To (stopValue)......Page 254
Repeat With (loopVariable) In (list)......Page 256
Exit......Page 258
Kinds of Errors......Page 259
How Errors Are Handled......Page 260
Try......Page 261
Error......Page 264
Considering and Ignoring Statements......Page 268
Considering/Ignoring......Page 269
With Timeout Statements......Page 272
With Timeout......Page 273
With Transaction......Page 275
Script Applications......Page 279
About Subroutines......Page 280
The Return Statement......Page 281
A Sample Subroutine......Page 282
Types of Subroutines......Page 283
Scope of Subroutine Calls in Tell Statements......Page 284
Checking the Classes of Subroutine Parameters......Page 285
Recursive Subroutines......Page 286
Saving and Loading Libraries of Subroutines......Page 287
Defining and Calling Subroutines......Page 289
Defining a Subroutine With Labeled Parameters......Page 290
Calling a Subroutine With Labeled Parameters......Page 291
Examples of Subroutines With Labeled Parameters......Page 293
Subroutines With Positional Parameters......Page 296
Calling a Subroutine With Positional Parameters......Page 297
Examples of Subroutines With Positional Parameters......Page 298
Command Handler Syntax......Page 300
Command Handlers for Script Applications......Page 302
Run Handlers......Page 303
Open Handlers......Page 305
Handlers for Stay-Open Script Applications......Page 306
Idle Handlers......Page 307
Quit Handlers......Page 308
Interrupting a Script Application’s Handlers......Page 309
Calling a Script Application From a Script......Page 310
Scope of Script Variables and Properties......Page 311
Declaring Variables and Properties......Page 312
Scope of Properties and Variables Declared at the Top Level of a Script......Page 313
Scope of Properties and Variables Declared in a Script Object......Page 316
Scope of Variables Declared in a Handler......Page 321
Script Objects......Page 325
About Script Objects......Page 326
Defining Script Objects......Page 327
Sending Commands to Script Objects......Page 328
Initializing Script Objects......Page 329
Defining Inheritance......Page 331
How Inheritance Works......Page 332
The Continue Statement......Page 336
Using Continue Statements to Pass Commands to Applications......Page 339
The Parent Property and the Current Application......Page 341
Using the Copy and Set Commands With Script Objects......Page 342
The Language at a Glance......Page 349
Common Scripting Tasks......Page 350
Constants......Page 354
Predefined Variables......Page 358
Commands......Page 359
Coercions......Page 363
References......Page 365
Operators......Page 367
Control Statements......Page 373
Handlers......Page 376
Variable and Property Assignments and Declarations......Page 378
Placeholders......Page 380
Operating System Errors......Page 384
Apple Event Errors......Page 385
Application Scripting Errors......Page 387
AppleScript Errors......Page 388
Document Revision History......Page 391
Glossary......Page 395
Index......Page 405