Scripting and Automating Your Mac
Second Edition Januar 2006
ISBN 978-0-596-10211-1
Weitere Informationen zu diesem Buch
Inhaltsverzeichnis |
Index |
Probekapitel |
Rezensionen |
Index
[ Symbols ], [ A ], [ B ], [ C ], [ D ], [ E ], [ F ], [ G ], [ H ], [ I ], [ J ], [ K ], [ L ], [ M ], [ N ], [ O ], [ P ], [ Q ], [ R ], [ S ], [ T ], [ U ], [ V ], [ W ], [ X ], [ Y ], [ Z ],
Symbols[ Top ]
& (ampersand), concatenation operator, 267
* (asterisk), multiplication operator, 258
\ (backslash)
in literal strings, 225
variable names, 107
^ (caret), exponentiation operator, 259
: (colon)
handler definition and call, 145
in handler definition and call, 145
in Macintosh pathnames, 232
POSIX path, don't use in, 234
record, name-value separator, 240
, (comma)
in global declaration, 163
in local declaration, 161
separating list items, 236
separating parameters, 143, 145
separating record items, 240
thousands separator illegal, 222
¬ (continuation character), 55, 85
entering, 85
how used in this book, 85
moved or removed by decompilation, 85
must be last thing in line, 85
{ } (curly braces)
delimiting lists, 236
delimiting records, 240
= (equals sign), equality operator, 260, 261
assignment, not, 102, 261
(not equals sign), inequality operator, 261
!= (not equal to), doesn't exist, 261
> (greater than), 261
(greater than or equal to), 262
>= (abbreviation for ), 262
« » (guillemets)
constructing data class object, 221
entering, 229, 325
raw four-letter code, entering, 325
- (minus sign), subtraction and unary negation operator, 258
- - (comment delimiter), 88
inside comment delimiters, 89
- - - - (direct object), 40, 340
optional or required, 340
< (less than), 261
<> (not equal to), doesn't exist, 261
£ (less than or equal to), 262
<= (abbreviation for £), 262
( ) (parentheses)
handler definition and call, 143
interpretation of commands, 267
order of operations, 267
(* and *) (comment delimiters), 89
commenting out, 89
nesting, 89
+ (plus sign), addition operator, 258
concatenation, not overloaded for, 258
' (single quote)
delimiting four-letter code, 40
string comparisons and, 299
" (quotation marks)
in comment delimiters, 89
delimiting literal strings, 225
in literal strings, 225
quote global property, 272
string comparisons and, 299
/ (slash), division (real) operator, 258
| (vertical bars)
appear spontaneously, 320
in comment delimiters, 89
legalize illegal variable names, 107
prevent terminology clash, 108, 194, 320
record item name (user property), 242
retarget handler call, 194
in variable names, 107
A[ Top ]
a reference to operator, 211
abbreviations, 90
<= (for £), 262
>= (for ), 262
app (for application), 220
does not equal, doesn't equal (for is not equal), 261
end (for block termination line), 92, 281
equal, equals, equal to (for is equal to), 261
expanded during decompilation, 54, 90
greater than (for is greater than), 261
how used in this book, 90
into (for to), 102
is not equal, isn't equal (for is not equal to), 261
isn't (for is not), 261
less than (for is less than), 261
prop (for property), 111
put (for copy), 102
ref (for a reference to), 211
then, omission of, 282
above (preposition), 143
abstract class, 336
accent marks, string comparisons and, 299
Accessibility API, 402
accessible on demand, 113
acgi dispatcher, 424, 517
action, Automator, 32
run handler, 457
virtues of, 452
writing, 452-458
actions and action messages (Cocoa), 439
actions of user, responding to automatically (see automatic location)
activate command, 279
adding folder items to event, 422
addition, 258
Address Book, 395
Adobe FrameMaker, 483-505, 519
AEDebug, 40
AEPrint, 39
aete, 62
static or dynamic, 62
viewing with EightyRez, 327, 517
(see also dictionary)
aeut, 343
terminology clashes with, 348
viewing, 343
after keyword, 200
against (preposition), 143
Aker, Philip, 45
alias, 232
coercion
file, 251
pathname, 251, 252
string, 251
Macintosh pathname, obtaining, 251
nonexistent, 232
coercion can create, 247
POSIX path property, 235
remote application, don't ask for, 390
specifier, 206, 232
alias list class (Finder), 356
all caps (constant), 276
all lowercase (constant), 276
Alldritt, Mark, xxi, xxii
ampersand (&), concatenation operator, 267
and (joining boolean labeled parameters), 144, 146
and operator, 259
announcement line, block, 91
any, 331
anything, 331
Apache, traditional Mac CGI with, 423
apart from (preposition), 143
API (application programming interface)
Accessibility, 402
AppleScript as, 9, 70, 354
apostrophe (see single quotes)
app (abbreviation for application), 220
appending
to a file, 372
to a list, 237, 265
Apple Developer Connection, 441
Apple event, 5, 34
AEDebug format, 41
AEPrint format, 39
AppleScript as expression of, 43
applet, order of processing, 426
blocking, 296
calling handler in compiled script file, 477
command, 35
compilation constructs, 315
details of sending, 37
dictionary, translation using, 311
direct object, 40, 340
optional or required, 340
efficiency, improving, 379
error, 38
four-letter code, 38
intercepting, 40, 280
logging, 280
minimizing number sent, 379
nonsensical, compiler lets you send, 324
null( ) object, 344
object specifier, 40
parameters, 40, 340
optional or required, 340
parts of, 37
query, 35
raw
entering as four-letter code, 325
sending, 478, 509
viewing, 40
reference, not sent by creating, 212
reference, sent by using, 210
registry, 342
repertory, 36
deficient (see GUI scripting)
reply, 35
ignoring, 36, 298
required, 342
result, 38, 340
sender, 35
sending without AppleScript, 508-515
send-to-self, 71
standardization, 342
system as postman, 37
target, 35
timeout, 36, 295
handling, 307
viewing, 40
WebSTAR, 423
(see also command; event)
Apple Event Log (Script Debugger), 40, 280
Apple event registry, 342
AppleScript
Apple events, expression of, 43
Apple events, sending without, 508-515
bugs (see bugs, AppleScript)
compiled, how and why, 52
compiler, 53
component (see AppleScript scripting component)
dictionary, 343
terminology clashes, 348
viewing, 343
different for each target application, 63, 77, 505
documentation, online, 519
"ease of use" myth, xv
English-likeness, 78, 357
error message strings often unhelpful, 489
extended by target applications, 77
file-level persistence not enforced by, 118
LISP-likeness, 80, 149, 154
little language, 76
logarithmic functions lacking, 6
multithreaded, not, 426
nature and flavor, 75-82
object-oriented, not, 80
places for using, 14-33
AppleScript Studio, 27, 437-451
applet, 26, 430-437
automatic location, 25, 418-429
Automator, 32
Cocoa application, 28
hyperlink, 30
internally scriptable application, 18
script editor application, 14
script runner, 22
Unix, 30, 407-417
preferences (pretty-printing), 318
programming, art of, 483-507
purpose, 76, 220
reasons for using, 3-13
calculation and repetition, 7
combining specialties, 11
customization, 9
reduction, 8
regular expressions lacking, 6, 76
runtime engine, 53
script object (see AppleScript script object)
scripting component (see AppleScript scripting component)
speed, 53, 378-385
string manipulation inferior, 76
Studio (see AppleScript Studio)
trigonometric functions lacking, 6, 76
version, 44, 274
used in this book, xvi
AppleScript Debugger (OSA language), 45
AppleScript Language Guide, xv, 382, 519
AppleScript script object, 129
current application is parent of, 129
global properties, 129, 271
name, 129, 271
overshadowing, 272
AppleScript scripting component, 44, 46
caches loaded dictionaries, 313
global properties, 271
loads scripting additions, 362
maintains state, 48
parent of script, 129
persistence, 49
pretty-printing, performs, 49
remembers variable names, 106
run script command creates separate instance, 148, 307
AppleScript Studio, 27, 437-451, 516
application bundle, resources within, 369, 443
application, preparing for final release, 451
calling Cocoa from, 440, 447
calling from Cocoa, 474-479
Cocoa messages, receiving, 444
Cocoa scripting, combining with, 474-479
Cocoa, relationship to, 438
components of, 441
dictionary, 147, 442
documentation, online, 442
event handlers, 147, 444
get script command fetches a copy, 473
scriptability, 472-479
scripting additions, application can contain, 61, 362
shortcomings, overcoming, 440
terminology, using elsewhere, 478
window management bug, 450
applescript URL protocol, 30
AppleScript Utility, 15, 421
AppleScriptKit dictionary, 147, 442
AppleShare volumes, 376
applet, 26, 59, 430-437
advantages of, 26
bundle, 59
compatibility, 59, 431
example, 436
locating resources inside, 369, 436
scripting additions, can contain, 61, 362
CGI application, 423
compatibility, 60
creating, 26, 59
with Unix, 412
dictionary, has none, 437
droplet, 59, 435
editing, 59, 431
errors thrown in, 301
event handlers, 432
events, multiple, order of processing, 426
formats, 60
idle handler, 432, 433
interrupting, 434
launching, 26, 433
lifetime events, 432
locates targeted applications on launch, preventing, 294
menus, 431, 432
open handler, 435
persistence, 435
improving with bundle, 436
quit, 431
can't, if applet is busy, 434
can't, without continue quit, 433
quit handler, 432
reopen handler, 432
run handler, 432
run-only, 59, 431
scriptability, 433, 435, 436
startup screen, 431
stay-open, 431
AppleTalk, 388
AppleWorks, 351
application
actions, script responding to, 428
attachable, 71, 427
combining, 11
current, 129
factored, 71
front, bring to, 279
frontmost, 9, 396
ID, 391
internally scriptable, 18
launching, 278
local, 387
location of, learning, 369
missing
at compile time, 64, 313
at decompile time, 65
name, getting right, 387
observable, 428
programming interface (see API)
quit, 279
recordable, 70
remote, 293, 366, 388-392
launching, 390
running, learning whether, 390, 396, 422
script (see applet)
scriptable, 6-7, 386-400
attribute, value may be reference, 209
coercion, requesting from, 246, 247
launches when dictionary consulted, 62, 313
object model, 182, 338, 344
operations and, 269
operators, may interpret differently from AppleScript, 270
scripting addition vs., 360
string considerations ignored, 270, 299
targeting, 386-392
terminology, vs. AppleScript's, 321
this book not about individual, xiv
Tiger, supplied with, 395-400
writing, 459-479, 521
(see also application, target)
specifier, 206
start up, if not already running, 278
switching, 9
target, 386-392
applet, prevent seeking prematurely, 294
application class specifier, 220, 292, 387
can't be found, 65, 66, 313
extends AppleScript language, 77
how located, 65
misidentified, 67
name, 387
name, changed by decompilation, 65
remote, 293, 366, 388-392
specifying as variable, 293
specifying dynamically, 294
state change, preventing, 296
version, specifying, 387
(see also target; application, scriptable)
unscriptable, 401-406
user chooses, 366
visible, 396
writing, 430-479
application bundle (see applet)
application class, 220
object model, start of, 338, 344
object string specifier, 220
getting the name right, 387
remote application, 388
XML-RPC or SOAP server, 393
application process class (System Events), 403
application programming interface (see API)
application responses (constant), 277, 298
Appscript (Python module), 514, 516
April (constant), 277
Aristotle, 506
arithmetic
date, 223
errors inevitable, 257
operators, 257
around (preposition), 143
art of AppleScript programming, 483-507
as operator, 246
(see also get as command)
ASCII character command, 225, 374
MacRoman only, 228
ASCII number command, 374
aside from (preposition), 143
ask (constant), 276
assignment
equals sign (=) does not perform, 102, 261
file object specifier, 232
file URL, 234
multiple, 102, 240
attributes, 206
record item, 241
nonexistent, 242
references and, 214
top-level entity, 113
variable, 101, 236
no implicit coercion, 245
asterisk (*), multiplication operator, 258
at (make command), 200, 351-352
at (preposition), 143
Attach Script to Folder script, buggy, 422
attachable, 70
applications, 71, 427
degrees of attachability, 71
attribute, 182, 195
accessing, 182
chain of ofs and tells, 185
it keyword not needed, 191
of multiple objects, 204, 347
application, value may be reference, 209
class encapsulation, compiler does not enforce, 324
coercion, by scriptable application, 246, 247
dictionary, how listed in, 337
fetching or assigning several at once, 206
inheritance, in dictionary, 335
value may be a reference, 196
(see also property; element)
audio file, getting info about, 396
August (constant), 277
Austin, J. L., 344
autocompletion (Script Editor), 16
autoinitialization, 104
automatic location, 25, 418-429
Automator, 32
action, 32
Run AppleScript, 32
virtues of, 452
writing, 452-458
documentation, online, 452
workflow, 32
in Finder contextual menu, 32
B[ Top ]
Babcock, Scott, 142
backslash (\) character
literal strings, 225
variable names, 107
bash, 407
escaping strings on command line, 412
BASIC, 52
BBEdit, 357, 518
attachable, 71, 427
automatic location, 25
contents property hard to use, 216
factored, 71
inserting text, 200, 355
insertion point elements, 200
Menu Scripts folder, 25, 427
offset property, terminology bug, 322
print settings class defective, 326
pseudo-classes (records) used by, 339
recordable, 70
Script menu, 23
implements persistence, 118
Shutdown Items folder, 25
Startup Items folder, 25
beep command, 367
before keyword, 200
beginning keyword, 199
begins with operator, 264
behind (synonym for after), 200
Belleudy-d'Espinose, Serge, 382
Bellhop, 24, 517
below (preposition), 143
beneath (preposition), 143
Berkowitz, Paul, xxi, xxii, 284, 434
beside (preposition), 143
between (preposition), 143
Big Cat, 24, 517
binary operator, 256
binding name with value, 100
bindings, Cocoa, 453
blank line after continuation character, 85
block, 91, 93
abbreviating termination line, 92, 281
arbitrary, 92
how referred to in this book, 91
indentation, 91
level, 95
nesting, 95
scope, 93, 156
bold (constant), 276
Bonjour name
choose remote application bug, 366
targeting remote computer by, 388
books about AppleScript, 522
boolean, 221
coercion, 248
integer, 259
string, 259
condition, 281
operators, 259
parameter, replaced by "with" or "without", 144, 146
boolean test (element specifier), 201
dictionary, not listed in, 347
failure may generate error, 203
lists, not implemented for, 203
workaround (sort of), 239
multiple tests, 203
performed by target application, 269
string considerations ignored, 299
bootstrap code (applet), 59
bounding rectangle class, 239
braces, curly
delimiting lists, 236
delimiting records, 240
branching, 281
bridge (AppleScript Studio), 440
Briggs, Don, 521
bugs, AppleScript
AppleScript Studio window management broken, 450
applet continue quit command doesn't quit, 434
as operator, class can't be a variable, 246
Attach Script to Folder script broken, 422
call soap command incompatible with many servers, 395
coercion between alias and Unicode text can fail, 252
coercion to integer but not to number, 250
colon in POSIX pathname misinterpreted, 234
empty run handler, stack overflow, 110
folder actions architecture flawed, 420
handler defined with prepositional parameters can be called with positional parameters, 145
list access speed, 382
list concatenated to empty list yields same list, 265
NSReceiverScriptError message, 472
open for access command creates file, 370
path to resource command doesn't locate Resources folder, 436
repeat with . . . in every, misbehaves, 289
script object assignment creates closure, 176
setting date/time string property of date yields stack overflow, 225
bugs, common
class specified instead of property, 192, 347
datatype of returned value not checked, 350
equals sign used for assignment, 102
explicit return missing, 136
folder action script triggers itself, 423
handler, saying name instead of calling, 135
implicit coercion, unexpected, 256
range specifier forms conflated, 199
repeat with . . . in every, 289
result keyword used unwisely, 87
return keyword encountered prematurely, 88
scripting addition missing, 356
undeclared variable trampled, 169
variable name incorrect, 106
building Xcode project, 441
built-in command, 278-280
built-in datatype, 220-243
bundle, 56
identifier, launching application by, 391
Resources folder, locating file in, 369
(see also script bundle; applet, bundle)
by (preposition), 143
bytecode, 52
compiled script is more than, 57
decompilation of, 54
requires dictionary, 65
bytes, raw, 221
entering Unicode characters as, 229
C[ Top ]
C language
arbitrary blocks in, 92
compiled language, 52
different from AppleScript
arithmetic operation, datatype of result, 257
continue statement, 284
do until, not like repeat until, 285
for loop vs. repeat with, 285
real to integer coercion, 249
scripting addition might be written in, 60
C++, return-by-reference, 219, 288
calculation and repetition, 7
call (see handler, call)
call chain, 300, 302
call method command, 447
call soap command, 393
incompatible with many servers, 395
call xmlrpc command, 393
Call*subroutine command, 437
cancel, in dialog, 300, 303
error dialog not displayed, 302, 364
capitalization (see case)
CarbonLib, 361
caret (^), exponentiation operator, 259
case
string comparisons and, 299
variable names and, 105
vertical bars and, 107
case (constant), 277
catch (error), 300, 302
selectively, 305, 306
CD/DVD, responding to insertion of, 419
CGI (common gateway interface), 423-426
Mac vs. Unix implementation, 423
chain of handler calls, 300, 302
chain of inheritance (script objects), 123
implicit, 127
chain of ofs and tells, 185
crucial to AppleScript programming, 195
where it ends, 189
character
composed, 228
escaped, 225
number, conversion, 374
Unicode, entering, 229
untypeable, entering in literal string, 225
character (string element), 227
learning number of, 279
Unicode-savvy, not fully, 228
Cheeseman, Bill, 519, 522
chevrons (« »)
constructing data class object, 221
entering, 229, 325
raw four-letter code, entering, 325
choose application command, 366
Choose Application dialog, 387
choose color command, 367
choose file command, 365
choose file name command, 365
choose folder command, 365
choose from list command, 365
choose remote application command, 366
choose URL command, 366
returns string (dictionary lies), 349
clash, terminology (see terminology, clash)
class, 105, 182, 220
abstract, 336
any can be assigned to variable, 182
coercion, 244
string, 250
commands that can be sent to, 183, 355
constant, 275
defined differently by different applications, 183
dictionary, how listed in, 334
can appear twice, 357
enumeration listed as, 334
inheritance, 335
record listed as, 339
finding list items of given, 239
implementing (Cocoa scripting), 463
orphan, 346
plural (synonym for every), 199
dictionary, how listed in, 335
repeat with . . . in, causes trouble, 289
singular, can be identical with, 335
some classes lack, 335
property of record, 339
property, same name as, 192, 347
compiler doesn't distinguish, 324
reference, never reported as, 212
type class vs., 182
used as variable name, 316, 317
of variable, 182
(see also datatype)
Classic scripting additions, 361
clipboard
conversion, 9
data, reading and writing, 374
styled text, 231
undisplayable values, 221
clipboard info command, 374
close access command, 372
close command (TextEdit), 357
closure, 175-179
Cocoa, 438
action messages, 439
Apple events, sending with, 478, 509
application
launches when dictionary consulted, 62
make command, 352
may look scriptable even if not, 342
scriptability, adding, 459-472
writing, with AppleScript Studio, 437-451
bindings, 453
built-in methods, 439
calling AppleScript from, 28, 477
calling AppleScript Studio from, 474-479
calling from AppleScript, 440, 447
delegation queries, 439
documentation, online, 442
key (sdef dictionary), 463
learning, 440
lifetime notifications, 439
messages from, receiving (AppleScript Studio), 444
methods, built-in, 439
Objective-C, native language, 438
scriptability (see Cocoa scripting)
Cocoa scripting, 459-472
AppleScript Studio, combining with, 474-479
class, implementing, 463
command, implementing, 470
dictionary format, 62
documentation murky, 459, 469
enumeration, implementing, 470
key-value coding, 464
disadvantages of, 467
NSReceiverScriptError, 472
pre-Tiger applications, 474
property, implementing, 463
code
coverage, Script Debugger provides, 379
fragments, 402
reusing, with a library, 122
script object or handler definition not, 99
code, four-letter (see four-letter code)
coercion, 244-255
alias, 251
by AppleScript, 246
boolean, 248
class, 250
constant, 250
date, 250
dictionary, not listed in, 245, 248, 356
explicit, 246
file, 251
file URL, 251
implicit, 244, 256
arithmetic operators, 257
boolean operators, 259
comparison operators, 260
concatenation operator, 265
containment operators, 262
list to string, being careful of, 254
list, 252
month, 250
number, 249
object string specifier vs., 246
pathname, 251
POSIX file, 251
reference, 212
by scriptable application, 247
by scripting addition, 244, 359
string, 249
pathname, 251
styled text, 250
text (synonym for string), 250
Unicode text, 250
pathname, 251
unit (measurement), 255
version, 250, 274
weekday, 250
colon (:)
in handler definition and call, 145
in Macintosh pathnames, 232
POSIX path, don't use in, 234
record, name-value separator, 240
color, rgb (class), 239
user chooses, 367
comes after (synonym for >), 261
comes before (synonym for <), 261
comma (,), 222
in global declaration, 163
in local declaration, 161
separating list items, 236
separating parameters, 143, 145
separating record items, 240
command, 35, 180, 278-280
classes that can obey, 183, 355
coercion, might perform implicit, 245
default is get, 190
event vs., 340
handler call similar to, 132
implementing (Cocoa scripting), 470
multiple objects, applied to, 205
multiple words, 147
multiple, to same target, 186
nested in another command, 83
parentheses needed, 267
parameter
datatype not enforced by compiler, 333
dictionary may list wrongly, 350
name enforced by compiler, 323, 341
result, 86
inconsistent datatype, 350
scripting addition, handler name same as, 317
used as variable name, 315
(see also event; Apple event)
comment, 88
command, can't interrupt or precede, 89
in dictionary, 358
multiple line, 89
nesting, 89
precedence, 89
quotation marks and pipes inside, 89
single-line, 88
comparison operators, 260
some implicitly dereference reference, 214
compatibility
applet, 60
applet bundle, 59, 431
compiled script file formats, 57
sdef dictionary format, 330
compilation, 52
application needed for, 64, 313
constructs Apple events, 315
dictionary needed for, 62, 311, 313
dictionary, loading of, 313
first time takes longer, 313
generates four-letter codes, 315
top-level entries initialized, 116, 159
variable scope and type determined, 158
when needed, 53
(see also compile; decompilation)
compile, 52
can't, due to defective dictionary, 348
can't, if alias doesn't exist, 232
can't, with some terminology clashes, 315
can't, without targeted applications, 64, 313
saving a script that won't, 58
with Unix, 412
(see also compilation; compiled script file)
compiled script file, 55
data storage, 120
formats, 56
compatibility problems, 57
data-fork file, 56
resource-fork file, 56
script bundle, 56
handler in, calling from Cocoa, 477
information contained in, 57
library of common code, 121
location of current, learning, 369
opening from Finder, 15
opening without target application, 66
persistence of top-level entities, 117
Script Debugger shows, 121
Script Editor destroys, 121
portability problems, 58
reading as script object, 118
can create undeclared variable, 170
loads context (closure), 178
recovering when decompilation fails, 59
running (see script, running)
run-only, 57
saving script object as, 118
saves context (closure), 178
Unix, creating with, 412
compiled vs. interpreted languages, 52
compiler, 53
class/property names not distinguished, 324
datatypes not checked, 333, 341
encapsulation not enforced, 324, 338
enforces class name in element specifier, 323
enforces command parameter names, 323, 341
enforces parts of speech, 315, 323
enumeration values not checked, 334
nonsensical expressions not prevented, 324
property and element not distinguished, 338
required parameters not enforced, 341
complete target, 185, 187
determination of, 189
reference as, 208
component, 44
Generic Scripting Component, 46
getting a list of, 377
from Unix, 411
instance, 48
Script Application Component, 59
(see also AppleScript scripting component)
Component Manager, 44
computer name, 368
computer, remote (see remote application)
concatenation, 265
avoids long literal strings, 85
plus sign (+), not, 258
record, 241
set end of, more efficient, 266
condensed (constant), 276
condition, 281
optimizing, 379
Configure Folder Actions, 421
considerations, string, 277, 298
offset command and, 374
scriptable applications ignore, 270, 299
considering block, 298
constant, 275-277
coercion, string, 250, 275
dictionary, how listed in, 334
display dialog displays incorrectly, 327
enumerator, 275, 334
global properties are not, 271
used as variable name, 316
constructor, 155
containment operators, 262
contains operator, 264
content property, 217
contents of operator, 214
contents property conflicts with, 216
contents property, 216
content a better alternative, 217
implicit subcontainer in Entourage, 346
context (of script object), 178
contextual menu
Big Cat, 24
Finder, Automator workflow, 32, 458
Script Editor, 16
continuation character (¬), 85
entering, 85
how used in this book, 85
moved or removed by decompilation, 85
must be last thing in line, 85
continue command, 126
passing parameters to run handler, 149
continue statement, nonexistent, 284
control structures, 281-308
branching, 281
errors, 300
deliberate, 304
looping, 283
not waiting for application reply, 298
pausing, 376
string comparison and containment, 298
targeting, 291
terminology resolution, 292
timeout, 295
conversion of units, 273
Cook, William, xxii
cooperative multitasking, 47
copy command, 101
can't be nested, 83
event handler illegal, 148
set command, difference from, 102
short-circuited resolution of, 181
copy, passing as parameter, 140
guaranteeing, 141
Core Suite, 342, 343
count command, 279
CPU speed, learning, 368
Creator, 72, 518
creator code, launching application by, 391
CRLF (Windows line break), 84, 227
curl (Unix tool), 409, 442
curly braces
delimiting lists, 236
delimiting records, 240
current application, 129, 277
implicit target, 133
location of, learning, 369
current date command, 376
customization, 9
application behavior
attachability, 70, 427
hooks, 426
observability, 428
attachability vs., 72
of handler, 154
of script object returned from handler, 154
D[ Top ]
data
clipboard, read and write, 374
file, read and write, 370
maintaining with store script, 120
overwriting, 372
raw, and data class, 221
raw, entering Unicode characters, 229
data class, 221
data fork, 56
Database Events, 399
datatype, 105, 182, 220-243
alias, 232
any can be assigned to variable, 182
application, 220
boolean, 221
built-in, 220-243
command result, inconsistent, 350
compiler does not check, 333, 341
constant, 275
conversion (see coercion)
data, 221
date, 222
in dictionary, 330
alternative, 333, 349
wrongly listed, 349
different
comparison, 260
equality, ascertaining, 261
file, 231
file specification, 235
file URL, 234
handler, 138
integer, 221
international text, 230
list, 236-239
machine, 220
mutable, 140
native, 220-243
number, 222
numeric, 221
miscellaneous rarely encountered, 222
POSIX file, 233
real, 221
record, 239-243
script object, 111
string, 225
styled text, 230
testing, 245
Unicode text, 228
of variable, 182
(see also class)
date, 222
arithmetic, 223
coercion, string, 250
comparison, 260
current, 222, 376
deriving one from another, 223, 225
mutation, 223
object string specifier, 222
passed by reference, 140, 224
property
calendrically impossible changes are legal, 223
changing mutates, 223
date string, 225
day, 224
hours, 224
minutes, 224
month, 224
seconds, 224
short date string, 225
time, 224
time string, 225
weekday, 224
year, 224
seconds, stored as, 223
set command sets by reference, 102, 224
specifier, 206
specifier property, 223
time zones, 223, 376
date string (date property), 225
date-time (see date)
day (date property), 224
day, trigger script on a certain, 426
days (global property), 273
days, names of, 277
debug
block structure, 92, 281
customize error message string, 304
hard to, so develop in small pieces, 506
it keyword, to understand target, 191
logging, 280, 506
references, 210
making get and it explicit, 193
result, 506
Script Debugger, 18
December (constant), 277
declaration
global, 157, 163
in loaded script object, 179
local, 157, 161
recommendations, 170
redeclaration, 172
script property, 111
variable, legal in control structure, 170
variable, not required, 103, 169
called harmful, 106, 169
decompilation, 54
abbreviations expanded, 54, 90
application and machine specifiers separated, 389
application needed for, 65
boolean labeled parameters replaced by with/without, 144, 146
bytecode insufficient for, 57
case of variable names changed, 105, 106
dictionary needed, 62, 311
escaped characters changed, 84, 226
failure, 59
lineation changed, 54, 85
long numbers rewritten, 222
parentheses inserted, 267
POSIX path changed to colon-delimited, 233
pretty-printing, 54
scientific notation literals rewritten, 222
singular/plural class name changed, 323
target application changed, 65
then keyword added, 282
unused target removed, 189
when target application is missing, 66
whitespace changed, 54, 85
default value for missing parameter, 142
dictionary doesn't list, 350
definition
handler, 134
initializes top-level entity, 104
script object, 109
script property, 111
variable, 103
delay command, 376
delegation (Cocoa), 439
delete item of list, 81
dereferencing (a reference), 213
needed in repeat with . . . in, 287
Description tab (Script Editor), 16
developer tools, 441
diacriticals (constant), 277
dialog, error, 300, 301
not displayed when user cancels, 302, 364
dialogs, StandardAdditions, 364
dictionary, 61, 311-358
AppleScript (see aeut)
AppleScriptKit (AppleScript Studio), 147, 442
applet, 437
application class as starting point, 338, 345
application launched by consulting, 62, 313
class with same name as property, 192, 347
coercions not listed, 245, 248, 356
commands not listed by class, 183, 355
Script Debugger helps, 356
comments usually inadequate, 358
compilation and decompilation, how used during, 62, 311
compilation, needed for, 64, 313
contents of, 329-343
creating, 461
datatypes in, 330
alternative, 333, 349
inaccurately listed, 233, 333, 349
decompilation, needed for, 65
display, 329
Script Debugger, 329
Script Editor, 16, 329
element specifiers listed in, 337
event handler defined by, 147
formats, 62
aete, 62
scriptSuite and scriptTerminology, 62
sdef, 63
four-letter code avoids need for, 325
four-letter codes mysteriously appear in, 326
graphical interface, might not match, 354
hidden terminology, 343
implicit subcontainers not listed, 345
inadequacy, 63, 333, 344-358, 506
inheritance, 335
how displayed, 336
innermost application, 313
internal implementation, need not match, 461
learning to read, 329
loading, 313
scripting addition, 360
omissions, 346
optional parameter default not listed, 350
remote application, 389
resolution of terminology, 312-323
scripting addition, 359
sdef, can be in Tiger, 63, 330
specifying which to use, 292
static or dynamic, 62
study of, major part of AppleScript programming, 311, 505
terminology clash caused by, 321, 322
(see also terminology; aete; sdef)
Dictionary (application), 7
looks scriptable but isn't, 7, 342
workaround with GUI scripting, 406
Digital Hub Scripting, 61, 419
direct object, 183
Apple event, 40, 340
optional or required, 340
command, 183
get command must be followed by, 191
multiple (as a list), 205
specifying target, 183
direct operation, 268
disk
get every (Finder), 350
list names of (StandardAdditions), 369
nonexistent, 232
dispatch
object-first, 470
verb-first, 477
dispatch table, 138
dispatch-based targeting, 294
display alert command, 364
display dialog command, 364
constant displayed incorrectly, 327
error if user cancels, 300
list, displaying, 254
Unicode text returned by, 409
distribution of command or attribute over list, 204
distribution of script, 32, 55, 122, 362
div operator, 259
division, 258, 259
remainder, 259
do shell script command, 407
Unicode text returned by, 230, 349
do until, 285
documentation
AppleScript Studio, online, 442
AppleScript, online, 519
Automator, online, 452
Cocoa, online, 442
dictionary often only (and poor), 312
does not come after (synonym for £), 262
does not come before (synonym for ), 262
does not contain operator, 264
does not equal, doesn't equal (abbreviation for is not equal to), 261
double integer, 222
drag and drop, 27, 59, 435
(see also droplet)
DragThing, 24, 517
drop box, 422
droplet, 27, 59, 435
example, 8, 435
open handler, 435
scriptability, 435
(see also applet)
dynamic dictionary, 62
dynamic nesting, 306
E[ Top ]
each (count command), 279
EightyRez, 517
learning four-letter codes with, 327
element, 195
class encapsulation, compiler does not enforce, 324
dictionary, how listed in, 337
how many there are, 198
inheritance, in dictionary, 337
manipulations can be performed on, 196
property, compiler doesn't distinguish from, 338
read-only, 337
referring to, 197
specifier, 197-206
applying command to resulting list items, 205
boolean test, 201
class name, enforced by compiler, 323
defective implementation, 347
dictionary, how listed in, 337, 346
every, 199
fetching attribute of resulting list items, 204, 347
ID, 198
index, 198
name, 197
random (some), 198
range, 199
reference returned may not match, 210
relative, 200
(see also object specifier)
(see also attribute)
else if keyword, 282
else keyword, 282
empty list or record, 236, 240, 263
concatenation to, bug, 265, 266
empty string, 225
coercion to zero, 249
encapsulation of class attributes
compiler doesn't enforce, 324, 338
inheritance in dictionary expresses, 336
encoding
AppleScript and, 228
MacRoman, 225, 228
styled text and, 231
Unicode, 228
UTF-16, 228
UTF-8, 230
end keyword, 91
in range specifier, 199
end transaction, FileMaker Pro bug, 297
ends with operator, 264
English-like terms (see terminology)
English-likeness, 78, 357
entity, top-level (see top-level entity)
Entourage, 518
contents property implicit, 346
fully delete messages, 10
properties with same name as classes, 347
recipient type, terminology clash, 348
run script in response to new mail, 25, 427
script format compatibility problems, 57
Script menu, 10
doesn't implement persistence, 118
selected messages, 354
signature, create, 13
entry point, 147
enumeration, 334
constants implemented as, 275
dictionary, how listed in, 334
implementing (Cocoa scripting), 470
incorrect value, 275
compiler doesn't complain, 334
enumerator, 334
constant, 275, 334
dictionary, how listed in, 334
eof (end of file), 372
eppc URL, 388
equal, equals, equal to (abbreviations for is equal to), 261
equality, 261
approximation may be better, 258
of different datatypes, ascertaining, 261
operator
doesn't coerce operands, 260
doesn't implicitly dereference reference, 214
repeat with . . . in and, 287
equals sign (=), equality operator, 260, 261
assignment, not, 102, 261
error, 300-307
Apple event, 38
arithmetic, 257
boolean test, nonexistent index, 203
catch, 302
deliberate, for flow control, 304
dialog, 300, 301
do shell script command, 408
handling, 507
during file access, 373
selective, 306
ignoring without terminating, 302
message
from application, 301
string often unhelpful, 489
(see also errors)
number, useful, 302
returning from Cocoa to AppleScript, 466
throw, 301
timeout, 295
handling, 307
transactions, 297
uncaught, 301
error block, 303
improving code structure with, 304
error command, 301
errors
an application constant or consideration can't go after this identifier, 267
access not allowed, 233, 275, 316
an error has occurred, 301
AppleEvent timed out, 296
can't continue, 133, 181, 189, 321, 437
often cured with me keyword, 194
can't declare as both a local and global variable, 172
can't get word after, 226
can't make file into type reference, 232
can't make into type, 182, 248, 256
file, 372
reference, 194
can't make some data into the expected type, 245, 292
can't set, 196, 316
doesn't match the parameters, 141
doesn't understand the message, 181, 251, 356
expected "end" but found "on", 96
expected "into", "to", etc. but found "get", 268
expected "tell", etc. but found, 316
expected class name but found identifier, 246
expected end of line but found, 323
expected expression but found
command name, 194
end of script, 191
expected expression but found command name, 316
expected variable name or property but found application constant or consideration, 275, 316
expected variable name or property but found command name, 315
expected variable name, class name or property but found command name, 316
file wasn't found, 233
no user interaction allowed, 413
NSReceiverScriptError, 472
property is specified more than once, 160
result of a numeric operation was too large, 296
run handler is specified more than once, 98
some object, 222
stack overflow, 110, 150, 225
syntax error, 222
unknown object type, 248
user canceled, 302, 364
variable is not defined, 103, 137, 160
escaped characters, 225
changed by decompilation, 84, 226
display, 84, 226
osascript and, 414
quoted form string property, 226
variable names, 107
Ethernet address, learning, 368
Eudora, 518
deleting a message, 355
element specifiers defective, 347
mailbox class orphaned, 346
making a new message, 351
evaluation, second-level, 307
converting list to record, 253
entering four-letter codes, 326
variable for record item name, 243
evaluation, suspended (reference), 209
event, 146, 180, 278
applet, order of processing, 426
command vs., 340
dictionary, how listed in, 340
observable, 428
(see also command; Apple event)
event handler, 146
AppleScript Studio, 444
applet, 432
scripting addition can define terminology, 359
user handler as, 427
Event Log, 16, 280
Apple Event Log (Script Debugger), 40, 280
good for understanding references, 210
History window (Script Editor), 16
tab (Script Editor), 16
every (element specifier), 199
class must have plural, 335
repeat with . . . in, causes trouble, 289
Excel, 518
supplying data and building a chart, 415
execute
handler (see handler, call)
script (see script, running)
exists command, 344
exit repeat statement, 283
expanded (constant), 276
expansion (constant), 277
experimentation, 492, 506
when dictionary is inadequate, 312, 333, 344-358
(see also guesswork)
explicit coercion, 246
explicit global, 157, 163
for shared access, 170
explicit local, 157, 161, 170
explicit result
of handler, 136
of line, 86
explicit run handler, 98
script object in, not persistent, 117
explicit target (see target)
Explorer view (Script Debugger), 18
exponentiation, 259
extended real, 222
extensions (pre-Mac OS X), 401
F[ Top ]
factored application, 71
false, 221, 276
without, replaced by, 144, 146
Fast User Switching, 388
FastScripts, 24, 517
speed, 385
February (constant), 277
fetch
attribute value, multiple, 206
top-level entity value, 113
variable value, 103
file
appending to, 372
audio, 396
creating, 233, 370
data, read and write, 370
existence of, testing, 252
hqx, decoding, 422
intermediary between Unix and AppleScript, 409
leave open, don't, 372
nonexistent, 232
obtaining information about, 235, 370
overwriting data of, 372
referring to, 231
specifier, 206, 231
assignment, 232
truncating, 372
Unicode text and, 229
user chooses, 365
UTF-8, 230
file class, 231
coercion
alias, 251
string, 247, 251
native vs. application, 235
POSIX path property, 235
File Sharing, toggling, 405
file specification class, 235
file URL class, 234
coercion, 252
Macintosh pathname, obtaining, 252
POSIX path property, 235
specifier string restrictions, 234
(see also POSIX file class)
FileMaker Pro, 20, 518
transactions, 296
filtered error handlers, 306
find item of list, 219, 288
Finder, 395
alias list class, 356
contextual menu
Automator workflow in, 32, 458
configuring folder actions, 421
run script from, 24
creating a window, 351
desktop-object class wrongly coded, 348
dictionary comments, bad and good, 358
element specifiers wrongly listed, 346
every disk, returns list or object, 350
file class vs. AppleScript file class, 235
Finder window elements omitted from dictionary, 346
folder, terminology conflict, 322
make command listed wrongly, 350
referring to desktop items, 345
rename items, 8
responding to events automatically (see folder actions)
reveal command returns result, 349
System Events handles some commands to, 390
toolbar, launching scripts from, 26
usually running, 395
fixed class, 222
flow control (see control structures)
folder
attach script to and remove from, 420
contents of, 235, 370
creating, 233
existence of, testing, 252
nonexistent, 232
obtaining information about, 235
pathname, getting, 254
referring to, 231
standard, getting location of, 369
user chooses, 365
folder actions, 25, 420-423
event handler called by, 147
example, 422
System Events, role in, 420
Folder Actions suite, 422
folder class
defined differently by different applications, 183
terminology conflict, 322
for (preposition), 143
for loop (see repeat block)
formatting preferences, 54
Fortran, 52
four-letter code, 38
application identifier, 391
assigning, when designing dictionary, 463
compilation translates to, 315
decompilation, preventing with run script, 326
dictionary, appears unexpectedly in, 326
dictionary, how used in, 329-343
display, conventions for, 40
entering in script, 325
event, convention for presenting, 340
integer, 40
learning
with EightyRez, 327
with Script Debugger, 327, 330
record item names and, 241
result of class coercion, 250
script, appears spontaneously in, 66, 326
scripting addition missing, 68, 326
scripting additions, Classic, 362
standard system folders, 369
standardization, 342
terminology clash, avoiding with, 326
terms with same, 348
fractional part of real, removing, 249, 259
FrameMaker, 483-505, 519
free variable, 171
closure, captured by, 176
value determined at runtime, 171
Friday (constant), 277
from (preposition), 143
from keyword, 199
Frontier, 22, 44, 516
XML-RPC or SOAP server, 394
(see also UserTalk; Radio UserLand)
frontmost application, 9
function (see handler)
furl (see file URL class)
G[ Top ]
Generic Scripting Component (GSC), 46
Generic Scripting System, 411
gestalt, 368
get as command, 246, 247
(see also as operator)
get command, 103, 190
is default, 190
direct object required, 191
event handler illegal, 148
implicitly supplied, 190
wrongly, 324
parentheses and, 268
presence or absence can matter, 190
repeat with . . . in, efficiency of, 291
resolves references, 190
retrieve variable value, 103
short-circuited resolution of, 181
get eof command, 372
get script command, 473
get volume settings command, 367
given keyword, 145
global
closure, not captured by, 176
declaration, 157, 163
accesses top-level script property, 166
creates and accesses top-level variable, 164
in loaded script object, 179
makes variable visible to deeper scopes, 163
shares variable among scope regions, 164
exists at top level, 164
explicit, 157, 163
for shared access, 170
redeclaration, 173
free variable, 171
in loaded script context, 179
implicit, 167
called harmful, 169
redeclaration, 172
not visible to deeper scopes without declaration, 164, 167
overshadowing of name, 164
parameter, instead of, 151
persistent, 165
reference to, creating, 217
run script command, not visible to, 307
scope, 163
top-level entity, similarity to, 166
global properties, 129, 271-274
accessing, 271
multiple-word names troublesome, 328
not constant, 271
scope, 271
value shared between scripts, 271
glue (UserTalk), 512
gluemac (Unix tool), 513
Goodman, Danny, 522
grammar, English, 357
GraphicConverter, 518
saving new file, 233, 349
greater than (>), 261
greater than (abbreviation for is greater than), 261
greater than or equal to (), 262
Gregorian calendar, 223
Gruber, John, 325
GSC (Generic Scripting Component), 46
guesswork, 356
AppleScript development is often, 506
GUI scripting, 401-406
guillemets (« »)
constructing data class object, 221
entering, 229, 325
raw four-letter code, entering, 325
H[ Top ]
handheld, trigger scripts with, 427
handle CGI request event, 423
handler, 94, 134-155
call, 94, 135
chain, 300, 302
from Cocoa, 477
command, similar to, 132
dynamic, 138
inheritance chain and, 131
itself (recursion), 149
me/it keyword not needed, 114, 125, 126, 131
parameters, 139
syntax, 141-146
target, directed to, 189
targeting script, 193, 321
targeting script, using vertical bars, 194
value of, 135
vs. merely saying name, 135
constructor of script object, 155
customized, generated by handler, 154
defining within a handler, 96
definition, 93, 134
code, is not, 99
initializes variable, 104, 134, 138
parameter names, 139
scope region, 156
syntax, 141-146
top level, 99
top-level entity, 134
where legal, 96, 134
entry point, 147
event, 146
applet, 432
user handler as, 427
free variables in, 171
inherited, calling with continue, 126
name same as scripting addition command, 317
as parameter, 151
parameters, 139
are locals, 162
name in definition is local, 162
named (labeled), 145
no implicit coercion, 245
none, 143
optional, 145
pass by reference, 140, 218
pass by value, 140
pass by value, guaranteeing, 141
positional (unnamed), 143
prepositional (labeled), 143
redeclaration, 172
references as, 218
testing datatype, 245
recursion, 149
result, 135
capturing or ignoring, 137
handler as, 153
reference as, 219
script object as, 153
run (see run handler)
scope block, 134
scope vs. callability, 160
script object in
can see handler's locals, 152, 162
definition must precede reference, 160
not persistent, 117
side effect, 135
targeting application dynamically, 218
top-level entity, 113, 134, 162
user, 146
instead of event handler, 427
no implicit coercion, 245
scriptable in applet, 436
as variable, 105, 138
recursive, 150
(see also top-level entity)
handling (error), 300, 303
selective, 306
hanging, preventing, 295
Harris, Warren, xxii
here document, 30, 414
hidden (constant), 276
hierarchy
inheritance (in dictionary), 336
object model, 338
defective, 344
Hillegass, Aaron, 440
hook, 426
Hopkins, Shirley, 522
hours (date property), 224
hours (global property), 273
hqx files, decoding, 422
HTML, parsing with Perl, 409, 442
HyperCard, 361, 517
(see also HyperTalk)
hyperlink, script embedded in, 30
HyperTalk, 43, 86
put command, 102
(see also HyperCard)
hyphens (constant), 277
hyphens, string comparisons and, 299
I[ Top ]
IAC (see interapplication communication)
iCal, 395
run script when alarm fires, 25, 426
iChat, 395
ID (element specifier), 198
id keyword, 198
ID property, 198
ID, application, 391
ID, transaction, 296
idle event handler (applet), 432, 433
iDo Script Scheduler, 426, 517
if block, 281
single-line form, 282
ignoring block, 298
iKey, 24, 517
Image Events, 398
image manipulation, 398
implicit coercion, 244, 256
arithmetic operators, 257
boolean operators, 259
comparison operators, 260
concatenation operator, 265
containment operators, 262
list to string, being careful of, 254
implicit dereferencing, 213
implicit global, 167
redeclaration, 172
value in loaded script context, 179
implicit local, 167
redeclaration, 172
repeat with, 285
implicit parent (inheritance) chain, 127
implicit result
of handler, 136
called harmful, 136
of line, 87
of script
useful, 88, 506
implicit run handler, 98
empty, causes stack overflow, 110
implicit subcontainer, 345
implicit target, 183
in (synonym for of operator), 185
in back of (synonym for after), 200
in front of (synonym for before), 200
incantation, reference as, 209
indentation, 91
index (element specifier), 198
index keyword, 198
index of this book, xxii
index property, 198
inequality operator, 261
doesn't coerce operands, 260
doesn't implicitly dereference reference, 214
repeat with . . . in and, 287
infinite loop, 283
info for command, 370
inheritance
chain (script objects), 123
implicit, 127
dictionary, classes in, 335
how displayed, 336
global properties made available, 271
handler calls and, 131
passing parameters to run handler, 149
polymorphism, 125
script object, 123
(see also parent)
initialization
free variables, 171
script property, 111, 115
top-level entity, 159
variable, 104
INITs, 401
innermost application dictionary, 313
insert into list, 238
insertion location, 200, 332
different applications expect different forms, 200, 351
insertion point elements (BBEdit), 200
instance of component, 48
instead of (preposition), 143
integer, 221
character, conversion, 374
coercion, 249
boolean, 249, 259
list, 257
month, 250
real, 249
string, 249, 257
weekday, 250
comparison, 260
division, 259
double, 222
literal, 221
month (date property) assignment, 224
random, 375
small, 222
intelligence (see control structures)
interapplication communication, 34
speed bottleneck, 378
(see also Apple event)
intercepting Apple events, 40, 280
interface
AppleScript Studio, 438
Automator action, 452
designing (AppleScript Studio), 441, 443
dialogs, StandardAdditions, 364
graphical vs. programming, 9, 70, 351, 354
interacting with, programmatically, 401
programming
Accessibility, 402
AppleScript as, 9, 70, 354
scripting additions, 360
scripting, vs. internal implementation, 461
Interface Builder, 441, 516
International System Preferences, 222
international text class, 230
Internet Connect, 395
Internet, AppleScript over (see remote application)
interpreted vs. compiled languages, 52
interrupt an applet, 434
into (abbreviation for to), 102
into (preposition), 143
introspection, record, 243, 339
IP number, targeting remote machine, 388
is (synonym for =), 261
is equal to (synonym for =), 261
is greater than (synonym for >), 261
is in operator, 264
is less than (synonym for <), 261
is not (synonym for ), 261
is not equal to (synonym for is not), 261
is not equal, isn't equal (abbreviation for is not equal to), 261
is not greater than (synonym for £), 262
is not in operator, 264
is not less than (synonym for ), 262
isn't (abbreviation for is not), 261
it is (not), in boolean test specifier, 202
it keyword, 191
accessing attribute of scriptable application, not needed, 191
accessing top-level entity, 114
in boolean test, 201
distinguish property from class, 192, 348
inheritance and, 124
polymorphism and, 125
target represented by, 191
italic (constant), 276
item (list element), 236, 239
learning number of, 239, 279
looping through each, 286
not a record element, 240
reference to, 286
(see also list)
item class
BBEdit, abstract, 336
Finder, not so abstract, 336
Finder, repeat with . . . in every, 289
iteration, jumping to next, 284
its (synonym for of it), 191
iTunes, 395
assign track numbers, 9
convert command, object datatype badly described, 333
referring to library or playlist, 345
Script menu, 10
selection, 354
J[ Top ]
Jaguar, xvi
resource-fork scripts and, 57
January (constant), 277
JavaScript OSA, 44, 45, 516
sending Apple events with, 511
joining list items, 253
(see also concatenation)
Jon's Commands, 356, 363, 379, 518
July (constant), 277
June (constant), 277
K[ Top ]
keyboard and mouse, simulating, 401
Keyboard Maestro, 24, 517
keyboard shortcut, for launching a script
DragThing, 24
FastScripts, 24
Keychain Access, 398
Keychain Scripting, 398
keychain, accessing, 398
key-value coding (KVC), 464
called harmful, 467
L[ Top ]
labeled parameters, 143, 145
multiple words, 147
lame (MP3 encoder), 452
language, AppleScript (see AppleScript)
languages, little, 76
Late Night Software (see Script Debugger; JavaScript OSA)
launch command, 278
sent to applet, 433
launchers, 24
launching a remote application, 391
length
list property, 239
record property, 241
string property, 226
less than (<), 261
less than (abbreviation for is less than), 261
less than or equal to (£), 262
level, top (see top level)
lexical nesting, 306
lexical scoping, 171
library, 121
ligatures, string comparisons and, 299
line
actually executed, learning, 379
break character, 83
display, 84
paragraph (string element) and, 227
string comparisons and, 299
changed during decompilation, 54, 85
expression is minimum valid, 86
long, 55
breaking, 85
broken manually in this book, 85
result, 86
terminator character, 83
display, 84
unit of AppleScript language, 83
wrapping, 55, 85
LISP, 80, 149, 154, 175, 257
(see also Scheme)
list, 236-239
appending to, 265
boolean test specifiers lacking, 203
workaround (sort of), 239
coercion, 252, 257, 259
scriptable application may refuse, 248
to string, being careful of, 254
comparison, 260
concatenation, 265
containment, 262
displaying, 254
distribution of attribute or command over, 204
efficiency of access, 237, 382
element
class name, 239
item, 239
empty, 236
concatenation to, bug, 265
filter items of, 150
closure-based example, 177
generalized example, 152
most elegant example, 154
of handlers, as dispatch table, 138
item
delete, 81
find, 219, 288
find, of given class, 239
insert, 238
looping through, 286
nonexistent, asking for, 203
set by reference, 237
joining, 265
joining string items, 253
making sure you have one, 253, 350
multiple variable assignment, 102, 236
mutation, 237, 288
repeat with . . . in, 288
one-item, forming, 248
parameter in handler call, 141
passed by reference, 140, 237
pointer to item of, returning, 219, 288
repeat with . . . in, 288
property
length, 239
rest, 239
reverse, 239
recursion, 238
set command sets by reference, 102, 237
size of, 239, 279
speed, 382
string manipulation, 254
user chooses from, 365
List & Record Tools, 243, 327, 518
list disks command, 369
list folder command, 370
list of (in dictionary value type), 333
little languages, 76
load, 56
load script command, 118
library, accessing, 121
loads context (closure), 178
Loader, 123, 517
local
declaration, 157, 161
explicit, 157, 161, 170
handler's
closures and, 177
visible to script object, 152, 162
implicit, 167
called harmful, 169
redeclaration, 172
repeat with, 285
overshadows global, 164
overshadows top-level entity, 161
redeclaration, 173
reference to, can't create, 217
scope, 161
local application, how specified, 387
location reference, 200, 332
different applications expect different forms, 200, 351
location, automatic, 25, 418-429
log command, 280
logarithmic functions, 6
logging, 280
Script Debugger, 40
Script Editor, 16
while developing script, 499
logic, programming (see control structures)
logical not sign (see continuation character)
Login Items
adding a script to, 27
manipulating with System Events, 396
System Events added when folder items enabled, 420
LOGO, 76
looping, 283
avoiding, 381
conditional, 284
for loop (see repeat block)
infinite, avoiding, 283
jumping to next iteration, 284
premature termination, 303
solve single case before, 506
speed and efficiency, 283, 379
M[ Top ]
Mac OS 9, xvi
scripting additions, 361
Mac::Glue (Perl module), 513, 516
machine class, 220
object string specifier, 388
specifying dynamically, 294
XML-RPC or SOAP server, 393
(see also remote application)
Macintosh Connectivity Classes, 342
Macintosh line break (\r), 84
result returned to Unix, 413
return global property, 272
Macintosh pathname, 232
macro program, 401
MacRoman encoding, 225, 228
Mail, 395
create email message, 20
create signature, 12
run script in response to new mail, 25, 427
Script menu, 24
selection (text), not implemented, 353
mail, run script on arrival of, 427
mailing lists about scripting, 522
Mailsmith, 351, 353, 518
dictionary comments excellent, 358
maintenance of state (see state, maintenance of)
make command, 350-353
optional parameters listed wrongly, 350
March (constant), 277
May (constant), 277
McGath, Gary, 517
me keyword, 193
can't continue error, cure for, 194
giving top-level script a name, 129, 166
inheritance and, 124
polymorphism and, 125
script (object) represented by, 193
targeting script, 193, 321
terminology clash, relationship to, 193, 320
measurement units, 255, 273
menu, contextual (see contextual menu)
menu, Script (see Script menu)
menus, applet, 431, 432
message, 180
error (see error)
handler call and command, 132
handler call sends to target, 189
script object, 95
sending is primary act of AppleScript, 220
which can be sent to which classes, 183, 355
methods, built-in (Cocoa), 439
calling from AppleScript, 440, 447
microphone window, 367
middle (element specifier), 197
min monitor depth command, 361
minus sign (-), subtraction and unary negation, 258
minutes (date property), 224
minutes (global property), 273
Miscellaneous Suite, 342
missing value, 276
returning from Cocoa to AppleScript, 472
mod operator, 259
Monday (constant), 277
month
coercion
integer, 250
string, 250
name of, 277
month (date property), 224
mount volume command, 376
mouse and keyboard, simulating, 401
movie, QuickTime, AppleScript in, 32
MultiAd Creator, 518
multiple words, terms consisting of, 147, 328
multiplication, 258
multitasking, cooperative, 47
music CD appeared event handler, 419
mutation, 102, 112, 218, 219, 288
date, 223
list, 237, 288
repeat with . . . in, 288
string, instead of, 254
record, 240
my (synonym for of me), 193
MySQL database, 393
N[ Top ]
\n (newline) character, 84
do shell script command and, 408
literal strings, 225
changed to whitespace, 84, 226
string comparisons and, 299
variable names, 107
name
application
getting right, 387
shortcuts for entering, 387
computer, 368
constant, 275
handler, vs. call, 135
interface elements (AppleScript Studio), 444
more than one for same value, 102, 112
multiple words, 147, 328
overshadowed, 158
accessing, 159
parameter, 139
error block, 304
local to handler, 162
preposition, 143
unnamed, 143
user-defined, 145
record items, 241
generating, from string, 253
learning, 243
same, but different four-letter code, 348
tell block, in scope within, 188
variable, 100
case of, 105, 107
legalizing with vertical bars, 107
misspelled, 106
persistent and shared between scripts, 106
rules for, 105
name (element specifier), 197
name property, 197
named keyword, 197
named parameter, 145
namespaces, 63, 77
clash, 188, 312
(see also terminology)
Nandor, Chris, 513
native datatypes, 220-243
Neeracher, Matthias, 513
negation, numeric, 258
negative index, 198
nesting
blocks, 95
considering and ignoring, 300
tell, 186, 191
tell and terms, 293, 314
try, 306
dynamic, 306
lexical, 306
regions of scope, 156
script objects, 113
inheritance (not), 127
persistence and, 115
targets, 189
network, AppleScript over (see remote application)
newline (\n) character
do shell script command and, 408
literal strings, 225
string comparisons and, 299
variable names, 107
next repeat statement, nonexistent, 284
no (constant), 276
nonscriptable applications, 401-406
not equals sign ()
entering, 261
inequality operator, 260, 261
not operator, 260
not sign, logical (see continuation character)
NoteTaker, 352, 518
notifications (Cocoa), 439
November (constant), 277
now, 222, 376
NSAppleEventDescriptor
Apple event, forming with, 479, 509
parsing, 29
NSAppleScript, 28
executeAndReturnError, 28
executeAppleEvent, 479
initWithContentsOfURL, 29
initWithSource, 28
script format compatibility problems, 57
null (constant), 276
null( ) (top-level object), 344
number, 221
character, conversion, 374
coercion
list, 257
string, 257
comparison, 260
digits, too many, rewritten, 222
error, 301
random, 375
scientific notation, 222
(see also integer; real; number class)
number class, 222
coercion, 249, 250
numeric classes, 221
miscellaneous rarely encountered, 222
numeric strings (constant), 277
O[ Top ]
object, 180
attributes, 182
accessing, 185
chain of ofs and tells, 185
coercion, by scriptable application, 246, 247
creating, 350
direct (see direct object)
model (see object model)
multiple, applying command to, 205
multiple, fetching attribute of, 204, 347
reference as means of access to, 209
script (see script object)
specifier, 40
"reference," in dictionary, 331
string specifier, 206
(see also object string specifier)
target, 183
viewing with Script Debugger, 18, 338
object model, 182, 338
defective, 344
figuring out, crucial, 338, 505
graphical interface, might not match, 354
internal implementation, need not match, 461
viewing in script editor application, 338
Script Debugger, 18, 338
object specifier, 40
(see also element, specifier)
object string specifier, 206
alias, 232
application, 220, 387-388
getting the name right, 387
coercion vs., 246
date, 222
file, 231
file URL, 234
machine, 388
POSIX file, 233
string can be literal or variable, 207, 292
XML-RPC or SOAP server, 393
object-based programming, polymorphism and, 126
object-first dispatch, 470
Objective-C, 438
Apple events, sending with, 478, 509
calling AppleScript from, 28, 477
calling AppleScript Studio from, 474-479
calling from AppleScript, 440, 447
learning, 440
object-oriented
AppleScript not really, 80
classes with inheritance not really, 336
objectSpecifier method, 466
observable events, 428
October (constant), 277
of (preposition), 144
direct object of command, 184
of operator, 185
accessing attribute of target object, 185
accessing top-level entity, 113
chain of ofs and tells, 185
preposition before direct object vs., 185
value containing is a reference, 212
when to use, vs. tell block, 187, 292, 386
(see also 's operator)
off styles, 276
offset command, 374
BBEdit terminology conflict with, 322
on (preposition), 143
on keyword, 94, 134
on styles, 276
OneClick, 401
onto (preposition), 143
open command (droplet), 435
open command (Unix), 41
open event handler (droplet), 435
open for access command, 370
open location command, 377
example, 9
Open Scripting Architecture (see OSA)
operand, 256
operation, 256
boolean test specifier, 269
direct, 268
order of, 267
operator, 256-270
arithmetic, 257
boolean, 259
coercion, may perform implicitly, 256
comparison, 260
concatenation, 265
containment, 262
scriptable applications may interpret differently from AppleScript, 270
or (alternative value types in dictionary), 333, 349
or operator, 260
order of execution (see control structures)
order of operations, 267
ordinal numeric literals, 198
orphan class, 346
OSA (Open Scripting Architecture), 43
compiling and running scripts, 46
component, 44
getting a list of, 377, 411
languages, 44
AppleScript Debugger, 45
JavaScript OSA, 44
OSABridge, 45
QuicKeys Script, 44
selecting, 45
UserTalk, 44
OSABridge, 45, 516
osacompile command, 412
osalang command, 411
osascript command, 30, 412-417
dialogs illegal, 364
osax, osaxen, 60
(see also scripting addition)
out of (preposition), 143
outline (constant), 276
over (preposition), 143
overshadowed, 158
global properties, 271
global, by local, 164
names, accessing, 159
not (free variable), 171
top-level entity, by local, 161
P[ Top ]
Panther, xvi
applet bundle introduced, 59
solves scripting addition distribution problem, 362
applet event processing order changed to FIFO, 426
month coercible to integer, 250
offset command obeys string considerations, 374
reals mostly coercible to integer, 249
script bundle introduced, 56
sdef introduced, 63
paragraph (string element), 227
parameter, 94, 139
Apple event, 40, 340
optional or required, 340
Automator action, 452
command, 340
another command as, 83
compiler enforces name, 323, 341
datatype not enforced by compiler, 333
dictionary may list wrongly, 350
optional, 350
required, compiler does not enforce, 341
error block, 303
literal (filtered error handler), 306
handler, 139
closures and, 177
datatype of, testing, 245
default value, 142
extra, ignoring, 142
named (labeled), 145
no implicit coercion, 245
none, 143
omitted (error), 141
optional, 141, 145
positional (unnamed), 143
prepositional (labeled), 143
visible to script object, 152, 162
handler as, 151
received by script object, 152
multiple words, 147
name in definition is local, 162
pass by reference, 218
vs. by value, 140
redeclaration, 172
reference as, 218
run handler, 148
osascript, supplying from, 414
script object as, 151
containing a handler, 152
parent, 123
implicit, 127
nested script object, 127
non-script object, 128, 130
setting, 123
(see also inheritance)
parentheses
handler definition and call, 143
interpretation of commands, 267
order of operations, 267
partial target, 185
parts of speech
enforced by compiler, 315, 323
four-letter code, 325
pass by reference, 218
preventing, 141
vs. by value, 140
password (bulleted) entry, 364
path to command, 369
coercion, Unicode text, 356
terminology conflict, 325
path to resource command, 369
can't locate Resources directory, 436
pathname
application, specifying by, 387
coercion
alias, 247, 251, 252
file object, 247
colon-delimited vs. slash-delimited, 231
components, breaking into, 499
creating file or folder, 233
existence of, testing, 252
folder, getting from pathname of item, 254
Macintosh, 232
obtaining, 251
nonexistent, 232
partial (called harmful), 232, 234
POSIX, 232
obtaining, 235
presented as colon-delimited, 233
pausing, 376
perform action command, 473
Perl
Apple events, sending with, 513
bigness of, 76
calling AppleScript from, 30, 414
calling from AppleScript, 409
HTML, parsing with, 409, 442
learning, 523
OSA language, 45
SOAP, communicating with via, 393
strict mode, no AppleScript analogue, 106
Unicode text, constructing with, 230
persistence, 49
applets, 435
compiled script files, 117
globals, 165
implementing with store script, 120
inconsistency, 118
top-level entities, 114
Personal File Sharing, 376
Personal Web Sharing, 425
Phlink, 25, 142, 427, 519
phone call, run scripts in response to, 427
PHP
OSA language, 45
SOAP, communicating with via, 393
pi (global property), 273
PICT data, 221
pipes (see vertical bars)
plain (constant), 276
plural (of class), 199
dictionary, how listed in, 335
repeat with . . . in, causes trouble, 289
singular, can be identical with, 335
some classes lack, 335
plus sign (+), addition operator, 258
concatenation, not overloaded for, 258
point class, 239
pointer, 219, 288
(see also reference)
polymorphism, 125
continue command, 126
portability
compiled script file, 58
date specifiers and coercions, 223
library, 122
(see also compatibility)
positional parameters, 143
POSIX file class, 233
coercion, string, 252
Macintosh pathname, obtaining, 252
presented as file class, 233
(see also file URL class)
POSIX path (property of file, alias, or file URL class), 235
POSIX pathname
colon, don't use in, 234
colon-delimited pathname vs., 232
specifying file or folder with, 233
power (exponentiation), 259
precedence, 257, 258
PreFab Player, 401, 517
premature termination
program (runtime error), 300
avoiding, 303
repeat block, 283, 303
prepositional parameters, 143
calling with positional parameters, 145
prepositions, 143
pretty-printing, 15
AppleScript scripting component performs, 49
blocks indented, 91
decompilation and, 54
formatting preferences, 54
preferences, 318
terminology clash, can help detect, 318
print depth (global property), 343
processes, running, 396
program, AppleScript (see script)
programming languages vs. scripting languages, 50
programming, AppleScript, art of, 483-507
project, Xcode, 441
prop (abbreviation for property), 111
property, 195
class encapsulation, compiler does not enforce, 324
class, distinguishing from with it keyword, 192, 348
class, same name as, 192, 347
compiler doesn't distinguish, 324
datatype not enforced by compiler, 333
declaration, 111
sets by reference, 111
dictionary, how listed in, 337
inherited, how displayed, 336
element, compiler doesn't distinguish from, 338
global (see global properties)
implementing (Cocoa scripting), 463
inheritance, in dictionary, 335
multiple-word names, 328
read-only, 196, 337
referring to, 197
script (see script property)
used as variable name, 317
fine if declared, 318
user, 241
value type, in dictionary, 333
(see also attribute; script property)
property keyword, 111
property list, parsing, 397
property specifier, 333
pseudo-class (record), 339
punctuation (constant), 277
punctuation, string comparisons and, 299
put (abbreviation for copy), 102
Python
Apple events, sending with, 514
learning, 523
OSA language, 45
Q[ Top ]
query, 35
QuicKeys, 44, 401, 426, 428, 517
QuickTime movie, AppleScript in, 32
quit command, 279
quit event handler (applet), 432
quotation marks (")
in comment delimiters, 89
delimiting literal strings, 225
in literal strings, 225
quote global property, 272
string comparisons and, 299
quote global property, 272
quoted form (string property), 226
R[ Top ]
\r (return) character, 84
literal strings, 225
changed to whitespace, 84, 226
result returned to Unix, 413
return global property, 272
string comparisons and, 299
variable names, 107
Radio UserLand, 22, 516
XML-RPC or SOAP server, 394
(see also Frontier)
random number command, 375
range (element specifier), 199
raw Apple event
sending, 478, 509
viewing, 40
raw data, 221
entering Unicode characters, 229
raw terminology (see four-letter code)
RCDefaultApp, 31
read command, 371
read-only
element, 337
property, 196, 337
real, 221
coercion, 249
integer, 249
list, 257
string, 249, 257
version, 250
comparison, 260
division, 258
extended, 222
fractional part, removing, 249, 259
literal, 222
making sure you've got one, 257
random, 375
rounding, 249, 375
scientific notation, 222
REALbasic, 509, 517
sending Apple events with, 510
recognition, speech, 367, 398
record, 239-243
begins with, ends with operators don't apply to, 264
class property, 339
clipboard, reading as, 375
coercion, 252
list, 253
comparison, 260
concatenation, 241, 265, 266
containment, 262
dictionary, how listed, 338
not distinguished from reference, 350
empty, 240, 263
concatenation to, bug, 266
generating from list of names and values, 253
item
assigning to, 241
changing value, 240
names are properties, 241
names, learning, 243, 339
set by reference, 240
variable for name, 243
joining, 265
mutation, 240
parameter in handler call, 142
passed by reference, 140, 240
property
length, 241
pseudo-class, 338
accessing outside tell block, 339
recursion, 241
result of XML-RPC or SOAP call, 393
set command sets by reference, 102, 240
size of, 241, 279
values, extracting a list of, 252
variables, multiple assignment of, 240
recordable, 70
Apple event, what constitutes, 71
application, 70
rectangle, bounding (class), 239
recursion
handler, 149
list, 238
record, 241
reduction, 8
ref (abbreviation for a reference to), 211
reference, 208-219
Apple event may be sent when using, 210
assignment, 214
attributes, may have, 196
capturing for use in deeper tell block, 187
coercion to, 212
comparison, 214, 215
copy, is not, 197
creating, 211
doesn't send Apple event, 212
to local, impossible, 217
terms block, 292
dereference, 213
explicit, 214
implicit, 213
dictionary, value type in, 331
record, not distinguished from, 350
file object, 232
incantation, 209
learning whether a value is one, 212
multiple, applying command to, 205
multiple, fetching attribute of, 204, 347
object, means of access to, 209
as parameter, 218
pass by, 140, 218
preventing, 141
repeat with . . . in generates, 286
resolved by get command, 190
result of fetching attribute, 196
result of handler or script object, 219
set by, 102, 111
specifier, may differ from, 210
target, 208, 386
complete, 196
tell block, 292
targeting application dynamically, 294
region of scope, 97, 156
regression, 496
regular expressions, 6, 76
relative (element specifier), 200
remainder, 259
Remote Apple Events, 294, 366, 388
toggling remotely via ssh, 388
remote application, 293, 366, 388-392
launching remotely, 390
user chooses, 366
Rendezvous (see Bonjour name)
reopen command, 279
reopen event handler (applet), 432
repeat block, 283
forever, 283
jumping out of, 283
jumping to next iteration, 284
premature termination, 283
repeat n times, 284
repeat until, 285
repeat while, 284
optimizing, 379
repeat with, 285
more efficient than repeat while, 380
repeat with . . . in, 286
avoiding inefficiency of, 290, 380
speed and efficiency, 283, 379
repertory
Apple events, 36
dictionary, 61
repetition and calculation, 7
reply, 35
ignoring, 36, 298
time to wait for, 36, 295
Required Suite, 342
resolution of terminology, 311, 312-323
compilation and, 64, 292
four-letter code avoids need for, 325
references and, 210, 386
tell block, 186, 292
terms block, 292
terms in scope and, 188
without targeting, 292, 386
(see also terminology, clash)
resource fork, 56
rest (list property), 239
restart computer, 396
result, 86
of Apple event, 38, 340
of arithmetic operation, 257
capturing, 86, 137
of handler, 135, 136
closure, 176
handler as, 153
reference as, 219
script object as, 153
ignoring, 137
inconsistent datatype, 350
of line, 86
of script, 137
implicit, useful, 88, 506
of script object, 137
from scriptable application
coercion, requesting, 246, 247
reference, often, 209
Result History window (Script Editor), 15
result keyword, 86
called harmful, 87
Result tab (Script Editor), 16
retrieve (see fetch)
return (\r) character
literal strings, 225
result returned to Unix, 413
return global property, 272
string comparisons and, 299
variable names, 107
return (global property), 272
return by reference, 219, 288
return keyword, 136, 283
implicit result vs., 88
omission of, 87
called harmful, 87
return global property vs., 272
returning a value, 135
returning command, 101
reverse (list property), 239
rgb color class, 239
\r\n (Windows line break), 84, 227
Robertson, Ray, 284
round command, 249, 375
rounding, 249, 375
Ruby, 415
calling AppleScript from, 415
learning, 523
OSA language, 45
run
handler (see run handler)
script, 98
script object, 98, 110
run command, 110
sent to applet, 433
run handler, 98
applet, 432
Automator action, 457
event handler, 148
explicit, 98
script object in, not persistent, 117
undeclared variable in, 168
implicit, 98
empty, causes stack overflow, 110
parameters, 148
osascript, supplying from, 414
script object has exactly one, 98, 110
run script command, 119
entering four-letter codes, 326
expensive, 148, 307
list to record conversion, 253
passes parameters to run handler, 148
runs within context (closure), 178
scope, 307
second-level evaluation, 307
variable for record item name, 243
run-only script, 57
AppleScript Studio, 451
applet, 59, 431
runtime engine, 53
S[ Top ]
's operator, 185
accessing top-level entity, 113
not synonym for prepositional "of", 184
(see also of operator)
Safari, 395
Salling Clicker, 25, 427, 518
Samba volumes, 376
Sanderson, Hamish, xxii, 514
Saturday (constant), 277
save command, creating file with, 233
say command, 367
Unicode text rejected, before Tiger, 251
scheduled running of script, 426
Scheme, 76, 80, 149
(see also LISP)
scientific notation, 222
rewritten at compile time, 222
scope, 93, 156-179
block, 93, 156
free variable, 171
global, 163
global properties, 271
in, 157
lexical, 171
local, 161
nesting, 156
overshadowing, 158
region, 97, 156
run script command, 307
targeting rules do not override, 188
screen, startup (applet), 431
script
bundle (see script bundle)
editing, 14
reinitializes top-level entities, 116
entry point, 147
file, 51
folder, attach to and remove from, 420
keyword, 94
me keyword represents, 193
name, 128, 129, 166
object (see script object)
parent (implicit) of script objects, 127
parent of, 129
premature termination (runtime error), 300
program vs., 50
property (see script property)
running
from another script, 118
automatic location, 25
contextual menu, 24
double-clicking, 26
editor, 14
keyboard shortcut, 24
login, 27
menu, 22
run handler is what runs, 98
run handler taking parameters, 148
scheduled, 426
from Unix, 412
user actions, responding to, 420, 428
web page request, respond to, 423
(see also AppleScript, places for using)
script object, is a, 51, 96, 109
scripting component operand, 51
structure of, 93-100
target, implicit, 183
verb (to drive), 50
(see also compiled script file; script object; top level)
Script Application Component, 59
Script Assistant (Script Editor), 16
script bundle, 56
compatibility problems, 57
contents, viewing with Script Editor, 411
example, 410
locating resources inside, 369
secondary script file inside, 121
Script Debugger, xxi, 18, 516
Apple events displayed, 40
AppleScript's dictionary shown, 343
attachability, erstwhile, 71
classes, multiple listings unified, 357
closes files left open, 373
code coverage provided, 379
commands and classes cross-referenced, 356
compiled script file contains text, 59
context of saved script object shown, 178
debuggable, makes AppleScript, 18
dictionary display, 329
element specifiers shown, 337
enumerations fully displayed, 334
escaped characters displayed, 84, 226
four-letter codes displayed, 327, 330
inherited attributes unified, 336
libraries, makes portable, 122
line break characters displayed, 84, 226
missing scripting additions identified, 362
object model displayed live, 18, 338
path to me command works, 369
path to resource command works, 369
persistence implemented, 117
persistent data in compiled script file shown, 121
picture data displayed as picture, 221
record distinguished from class, 339
scripting component instance different for each script, 107
speed, 385
helps measure, 379
start log, stop log work properly, 280
suites avoidable, 329, 342
tell block, shortcuts for entering, 387
version used in this book, xvi
(see also script editor application)
Script Editor, 15
class not distinguished from record, 339
contextual menu, 16
dictionary display, 16
improved in Tiger, 329
element specifiers omitted, 337, 346
enumerator display, 334
file formats created by, 57
inherited attributes in, 336
Panther bug, balks at coercing file to alias, 251
path to me command broken, 369
path to resource command broken, 369
persistence destroyed, 117
persistent data destroyed, 121
POSIX pathname with colon fails, 234
script bundle contents shown, 411
scriptability, 395
speed, 385
start log, stop log not understood, 280
tell block, shortcut for entering, 387
version used in this book, xvi
(see also script editor application)
script editor application, 14
AppleScript, needn't know, 46
default, 15
how compiles, pretty-prints, and runs code, 47
Script Debugger, 18
Script Editor, 15
Smile, 17
script keyword, 94
Script menu, 23
Apple's global, 24
Automator workflow in, 32
persistence bug (and workaround), 118
runtime errors fail silently, 302
slow, 384
System Events responsible for, 397
BBEdit, 23
Entourage, 10
FastScripts, 24
iTunes, 10
Mail, 24
persistence and, 118
target application's, fastest, 384
various applications, 23
script object, 94, 109-133
AppleScript, 129
closures, 175
coercion, string (Jon's Commands), 356
context, 178
current application, 129
definition, 93, 109
code, is not, 99
initializes variable, 104, 109, 111
scope region, 156
top level, 99
top-level entity, 109
where legal, 109
free variables in, 171
closures, 175
in handler
can see handler's locals, 152, 162
definition must precede reference, 160
not persistent, 117
inheritance, 123
calling inherited handler, 126
passing parameters to run handler, 149
polymorphism, 125
script is implicit parent, 127
me keyword represents, 193
as parameter, 151
parent, 123
nested script object, 127
non-script object, 128, 130
script as a whole, implicitly, 127
passed by reference, 140
persistence, 114
implementing with store script, 120
property (see script property)
reading compiled script file as, 118
can create undeclared variable, 170
loads context (closure), 178
reference as result of, 219
as result of handler, 153
closure, 176
constructed, 155
customized, 154
run handler (see run handler)
running, 110
run handler is what runs, 98
run handler taking parameters, 148
saving as compiled script file, 118
saves context (closure), 178
scope block, 109
script as a whole, 96
set command sets by reference, 102, 112
target, implicit, 183
top-level entity, 109, 113
not, if not defined at top level, 160
as variable, 105, 111
(see also top-level entity)
script property, 111
declaration, 111
sets by reference, 111
initialization, 111
persistence and reinitialization, 115
recommended over global, 170
scope, 158
as static variable, 165
top-level entity, 113
top-level, accessible by global declaration, 166
(see also top-level entity)
script runner, 22
script text file, 58
line breaks, 84
Script Timer, 426, 517
scriptability, 6
AppleScript Studio application, adding, 472
applet, 433, 435, 436
Cocoa application, adding, 459-472, 521
pre-Tiger, 474
customizability and, 10
droplet, 435
internal, 18
modes of, 69
attachable, 70
recordable, 70
scriptable, 36, 69
application, knowing whether, 6-7, 342
(see also application, scriptable)
scripting addition, 60, 359-377
coercion, can define, 359
coercion, dictionary doesn't list, 356
command, handler with same name, 317
dictionary, 62
event (command), can define, 359
event handlers defined by, 147, 359
installing and loading dynamically, 363
loading, 362
from within application, 61, 362
locations, 60, 362
Mac OS X-native vs. Classic, 361
missing, 68
from other user's machine, 362
generates four-letter code, 68, 326
osascript command, dialogs illegal, 364
record (pseudo-class), can define, 359
remote applications, 390
repository, online, 361, 521
script communicates with, how, 61
scriptable application vs., 360
speed, 383
targeted, can't be, 181
terminology clash, 61, 320
notorious source of, 322
writing, 520
scripting components command, 377
scripting languages, 50
AppleScript Debugger, 45
JavaScript OSA, 44
OSA implements, 44
OSABridge, 45
QuicKeys Script, 44
UserTalk, 44
scripting languages vs. programming languages, 50
scriptSuite and scriptTerminology, 62
generating from sdef, 475
sdef, 63
alternative value types expressible, 349
can be dictionary in Tiger, 63, 330
classes can list commands they obey, 356
command and events distinguished, 340
comments extensive and formatted, 358
compatibility, 330
converting to scriptSuite and scriptTerminology, 475
creating, 461
distinguishes record from class, 339
improved in Tiger, 63, 330
introduced in Panther, 63
Sdef Editor, 461, 521
sdp, 63, 474
second-level evaluation, 307
converting list to record, 253
entering four-letter codes, 326
variable for record item name, 243
seconds
converting to, 273
date stored as, 223
seconds (date property), 224
security (hiding script contents), 58
select command, 354
selection, 353
learning with GUI scripting, 405
setting, 354
selection-object class, 216
sender, 35
blocking another, 296
Sentman, James, 424
September (constant), 277
sequential read and write, 370
server
AppleShare or Samba, 376
finding, 366
web (CGI), 423
XML-RPC or SOAP, 392
targeting dynamically, 394
Services menu, run script from, 24, 517
services, web, 392
set by reference, 102, 111, 237
set command, 101
can't be nested, 83
copy command, difference from, 102
direct object required, 191
efficiency, 112
event handler illegal, 148
script objects and, 112
short-circuited resolution of, 181
set end of, vs. concatenation, 266
set eof command, 372
set the clipboard to command, 374
set volume command, 367
sh, 407
OSA language, 45
shadow (constant), 276
shared variable (see global)
shell
escaping string for, 226
interactive, 408
parsing and quotation rules, 409
Unicode text, creating, 230
user's might differ from do shell script command's, 407
Sholdt, Chuck, xxi
short date string (date property), 225
short-circuited terminology, 181
short-circuiting (boolean operators), 259, 260
shut down computer, 396
side effect, 135
single quotes (')
four-letter code, delimiting, 40
string comparisons and, 299
sips (Unix tool), 398
Siracusa, John, 56
slash (/), division (real) operator, 258
sleep computer, 396
small caps (constant), 276
small integer, 222
Smalltalk, 76, 80
Smile, 17, 517
AppleScript's dictionary shown, 343
attachable, 71
compiles and executes individual lines, 53
start log, stop log not understood, 280
SOAP, 392-395, 520, 522
example, 12
general, 394
software, mentioned in this book, 516
some (element specifier), 198
sound, 367
file, save text-to-speech as, 367
space
names containing, 107
string comparisons and, 299
space (global property), 272
SpamSieve, 11, 518
specialties, combining, 11
specifier
element (see element, specifier)
object, 40
object string, 206
value type, in dictionary, 331
speech, 367
recognition, 398
text in microphone window, 367
SpeechRecognitionServer, 398
example, 368
speed, 378-385
AppleScript, in general, 53, 378
context of execution, 384
list access, 382
list vs. string, 254
loops, 283, 379
measuring, 379
run-only scripts, 57
scripting additions, 383
splash screen (applet), 431
splitting strings, 227
sqlite (Unix tool), 399
SQLite database, 399
stack overflow
empty run handler, 110
recursion depth, 150
Standard Suite, 342, 343
creating, 461
presence doesn't prove scriptability, 342
StandardAdditions, 61, 363-377
dictionary lies, 349
folder action event handlers, 147, 422
terminology conflicts, 322, 325
Unicode compatibility improved in Tiger, 251, 364
start log command, 280
starts with (synonym for begins with), 264
startup screen (applet), 431
state, maintenance of
beyond scripting component instance, 49
OSA scripting component, 48
target application, 296
static variable, 165
stay-open applet, 431
problems quitting, 433
Stone, Andrew, 521
stop log command, 280
store script command, 119
stores context (closure), 178
strikethrough (constant), 276
string, 225
coercion, 249
alias, 251
boolean, 249, 259
class or constant, 250
constant, 275
date, 250
list, 253
number, 249, 257
POSIX file, 252
script object (Jon's Commands), 356
Unicode text and styled text, 250
version, 274
comparison, 260
string considerations govern, 298
concatenation, 265
set end of (list), more efficient, 266
Unicode text, 265
considerations, 277, 298
offset command and, 374
scriptable applications ignore, 270, 299
containment, 262
string considerations govern, 298
display, 84
do shell script command and, 408
element, 226
character, 227
paragraph, 227
text, 227
text item, 227
word, 227
empty, 225
encodings, 228
escaped characters in literal, 225
joining, 253, 265
line breaks within, 84
long literal, breaking, 85
in object string specifier, 207, 292
osascript, constructing for, 414
property, 226
length, 226
quoted form, 226
size of, 226, 279
splitting, 227
styled text disguised as, 231
substrings, 227
counting, 227
finding, 374
transforming to list and back, 254
vs. Unicode text, 228
(see also Unicode text class)
StuffIt Expander, 422, 518
dictionary lies, 349
style constants, 276
styled text class, 230
coercion, 250
subclass, 336
subcontainer, implicit, 345
subroutine (see handler)
subscript (constant), 276
substrings, 227
counting, 227
finding, 374
subtraction, 258
suite, 341
AppleScript's dictionary, 343
called harmful, 329, 341
class can appear in more than one, 357
Core, 342, 343
escaping with Script Debugger, 329, 342
Folder Actions, 422
Macintosh Connectivity Classes, 342
Miscellaneous, 342
Required, 342
Standard, 342, 343
creating, 461
presence doesn't prove scriptability, 342
standardization, 342
Text, 342, 344
presence doesn't prove scriptability, 342
Type Names, 343
summarize command, 374
Sunday (constant), 277
superclass, 336
superscript (constant), 276
synonyms, 78, 90
behind (for after), 200
called harmful, 90
class plural (for every), 199
comes after (for >), 261
comes before (for <), 261
does not come after (for £), 262
does not come before (for ), 262
how listed in this book, 90
in (for of operator), 185
in back of (for after), 200
in front of (for before), 200
is (for =), 261
is equal to (for =), 261
is greater than (for >), 261
is less than (for <), 261
is not (for ), 261
is not equal to (for is not), 261
is not greater than (for £), 262
is not less than (for ), 262
its (for of it), 191
my (for of me), 193
starts with (for begins with), 264
text (for string, in coercions), 250
through (for thru), 199
to (for on), 134
whose (for where), 201
system
extensions (pre-Mac OS X), 401
folders, getting location of, 369
getting information about, 368
liberal in interpreting string as date, 222
postman for Apple events, 38
system attribute command, 368
System Events, 396-397
Finder, handles some commands to, 390
folder actions, 420-422
GUI scripting, 401
path to, terminology conflict, 325
Script Menu, responsible for, 397
system info command, 368
System Preferences, scriptability, 405
System Profiler, 395
T[ Top ]
\t (tab) character
literal strings, 225
changed to whitespace, 84, 226
string comparisons and, 299
tab global property, 272
variable names, 107
tab (global property), 272
Take Control ebooks, 32
target, 35, 180, 183
applet, prevent seeking prematurely, 294
application class specifier, 220, 292
getting the name right, 387
multiple versions of application, 387
complete, 187
chain of ofs and tells, 185
determination of, 189
reference is, 196
determination of, 189
dynamic, 218
handler call sent to, 189
implicit, 183
current application, 133
it keyword represents, 191
multiple commands to same, 186
nested, 189
partial, 185
reference as, 208, 386
remote, 293, 366
script (me keyword), 193, 320
script object, 110
scripting addition can't be, 181
specifying, 183
dynamically, 294
in place of direct object, 183
tell block, 184, 292, 386
as variable, 293
without resolving terminology, 292, 386
XML-RPC or SOAP server, 393
target application (see application, target)
Tcl (as OSA language), 45
tcsh, 407
telephone call, run scripts in response, 427
tell block, 291
advantages, 186
application name, getting right, 387
chain of ofs and tells, 185
dictionary, causes loading of, 313
four-letter codes, instead of, 325
nested, referring to higher-level target, 187, 191
nesting with terms block, 293, 314
reference, instead of, 210
shortcuts for entering, 387
single-line version, 291
specifying target, 184, 292, 386
targeting script from within, 193, 321
terminology within, 188, 292, 386
resolution of, 313
top-level entity, accessing, 114
when to use, vs. of operator, 187, 292, 386
when to use, vs. terms block, 292, 386
XML-RPC or SOAP server, targeting, 393
tell keyword, 184
Terminal, 452, 457
termination line, block, 91
abbreviating, 92, 281
termination, premature
program (runtime error), 300
avoiding, 303
repeat block, 283, 303
terminology, 311
AppleScript (see aeut)
AppleScript Studio, 442
using elsewhere, 478
clash, 63, 77, 194, 312, 315-323
AppleScript's dictionary helps explain, 343
defective dictionary causes, 348
end transaction, FileMaker Pro, 297
four-letter code, avoiding with, 326
may prevent compilation (or not), 315
me keyword, relationship to, 193, 320
pretty-printing can help detect, 318
record item name, 242
resolving, 320
scripting additions, 61, 322
vertical bars prevent, 108, 194, 320
constructing dynamically, 307
different for every application, 63, 77
event handler, 359
hidden, 343
multiple-word, 328
remote application, 389
resolution, 311, 312-323
compilation and, 64, 292
four-letter code avoids need for, 325
references and, 210, 386
tell block, 186, 292, 386
terms block, 292
terms in scope and, 188
without targeting, 292, 386
scripting addition, 360
standardization, 342
(see also dictionary)
terms block, 292
applet behavior, improves, 294
dictionary, causes loading of, 313
dictionary, specifies, 292, 314
dynamic targeting and, 294
nesting with tell block, 293, 314
remote applications and, 293, 389
resolution of terminology within, 313
when to use, vs. tell block, 292, 386
Terry, Michael, xxii, 145
test, boolean (see boolean test)
Tex-Edit Plus, 357, 518
text
clipboard, read and write, 374
encodings, 228
file, read and write to, 370
line breaks and compilation, 84
Unix and AppleScript, passing between, 409
user enters, 364
(see also string)
text (string element), 227
text (synonym for string in coercions), 250
text class
is its own plural, 335
vs. string, 226
text file
creating, 370
read and write, 370
script, 58
text item (string element), 227
text item delimiters (global property), 227, 253, 272
terminology resolution trouble, 328
text style constants, 276
Text Suite, 342, 344
presence doesn't prove scriptability, 342
text to speech, 367
TextEdit
close without saving, can't, 357
workaround with GUI scripting, 405
scriptability substandard, 395
selection, not implemented, 353
workaround with GUI scripting, 405
the, 78, 92
the clipboard command, 375
then keyword, 281
omission of, 282
thousands separator illegal, 222
threading, 426
through (synonym for thru), 199
throw (error), 300, 301
thru (preposition), 143
thru keyword, 199
Thursday (constant), 277
ticks, 363, 379
TidBITS, 409, 442
Tiger
AppleScript Studio window management changed, 450
application short name works in specifier, 387
Automator introduced, 32
choose remote application command introduced, 366
display alert command introduced, 365
forks, multiple, 56
Mail loses Script menu, 24
month (date property) settable by integer, 224
path to me command improved, 369
quote global property introduced, 272
remote targeting, scripting addition dialogs disabled, 390
run handler can receive parameters from osascript, 414
scripting addition dialogs in osascript blocked coherently, 413
sdef can be dictionary, 63, 330
sdef format improved, 63, 330
system info command introduced, 368
Unicode compatibility improved, 228, 251, 265
version coercion changed, 250
version used in this book, xvi
weekday coercible to integer, 250
time (date property), 224
time (see date)
time string (date property), 225
time to GMT command, 376
time zones, 223, 376
time, trigger script at a certain, 426
timeout, 36, 295
handling, 307
timeout block, 296
times keyword, 284
to (synonym for on), 134
to keyword (in range specifier), 199
today, 376
tokens, 52
toolbar, launching scripts from, 26
top level
block, 95
global lives at, 164
name, 128, 129, 166
parent of, 129
parent of script objects, implicit, 128
script, 96
script object or handler definition, 99
top-level entities of, referring to, 128, 167
variable, undeclared, 167
top-level entity, 93, 113, 157
accessible on demand, 113
applet scriptable with respect to, 437
assign and retrieve value, 113
closure, captured by, 176
definition is initialization, 104
free variable, 171
handler call automatically accesses, 131
handler has no, 162
inheritance chain, sought in, 123
overshadowing of name, 158, 161
persistence, 114
implementing with store script, 120
redeclaration, 174
reference to, creating, 217
run script command, not visible to, 307
scope, 158
at top level, referring to, 128, 167
value in loaded script context, 179
visible before its definition, 159
transaction, 296
ID, 296
transaction block, 297
tree (see hierarchy)
trigonometric functions, 6, 76
true, 221, 276
with, replaced by, 144, 146
truncating a file, 372
try block, 302
exiting repeat block, 283
improving code structure with, 304
nesting, 306
Tuesday (constant), 277
type, 182, 333
value types in dictionary, 330
alternative, 333, 349
wrongly listed, 349
type class, 182, 333
Type Names Suite, 343
U[ Top ]
UI Actions, 428, 518
UI Browser, 404, 517
UI element class, 403
UIElementInspector, 404
unary operator, 256
uncaught errors, 301
undeclared variable, 158, 167
called harmful, 169
undefine variable, 104, 136
under (preposition), 143
underline (constant), 276
Unicode, 228
do shell script command and, 408
string comparisons and, 300
Unicode text class, 228
coercion, 250
alias, buggy, 252
path to command, 356
concatenation with string, 265
creating a literal, 229
display, 228
do shell script command and, 408
vs. string, 228
(see also string)
units (Unix tool), 255
units, measurement, 255, 273
Universal Access, 403
Unix, 407-417
calling AppleScript from, 30, 411-417
calling from AppleScript, 407-411
learning, 523
line-break character (\n), 84
do shell script command and, 408
unscriptable applications, 401-406
until keyword, 285
upper case class, 343
URL
applescript, 30
eppc, 388
opening, 8, 377
XML-RPC or SOAP server, 393
URL Access Scripting, 398
user
actions
run script in response to, 428
simulating, 401
environment variables, 368
getting info about, 396
interaction (see interface)
targeting (see remote application)
user domain, terminology conflict, 325
user handler, 146
applet, scriptable in, 436
instead of event handler, 427
user property, 241
UserLand Frontier (see Frontier)
UserTalk, 22, 44
Apple events, sending with, 511
bundle construct, 92
(see also Frontier)
using terms from (see terms block)
usrf (list of user properties), 241
UTF-16 encoding, 228, 408
UTF-8 encoding, 230, 408
UTI (Uniform Type Identifier), 365
V[ Top ]
value
assigning to variable, 101, 182
no implicit coercion, 245
attribute, reference vs. copy, 196
class, 182
testing, 245
coercion, 244
constant, 275
datatype, 182, 220
converting, 244
testing, 245
default, of parameter, 142
file object specifier, 232
free variable, 171
global properties, shared between scripts, 271
handler as, 138
handler call, 135
none, 136
initial, 104
missing, 276
numeric, approximation, 257
object-like qualities, 180
pass by, 140
guaranteeing, 141
passing to handler, 139
placeholders for unassigned, 104
record item name is not, 243
reference, 208
returned, 135
script object as, 111
top-level entity, 113
type (in dictionary), 330
alternative, 333, 349
wrongly listed, 349
undefined, 103
variable, 100
retrieving from, 103
variable, 100
application object specifier, 292
assignment, 101
multiple, 236, 240
no implicit coercion, 245
class, 182
can be assigned value of any, 182
coercion, can't be used for class in, 246
constant is not, 275
declaration legal in control structure, 170
declaration not required, 103, 169
called harmful, 106, 169
defined, learning whether, 104
definition, 103
file object specifier, 232
file URL can be assigned to, 234
free (see free variable)
global (see global)
handler as, 138
initialization, 104
kinds, 157
determined at compile time, 158
local (see local)
name, 105
case of, 105, 107
legalizing with vertical bars, 107
misspelled, 106
persistent and shared between scripts, 106
same as class name, 316, 317
same as command name, 315
same as constant name, 316
same as property name, 317, 318
object string specifier, 207, 292
predefined, 271
record item name, 243
redeclaration, 172
scope, 157
determined at compile time, 158
script object as, 111
shared, 164
static, 165
target application as, 293, 294
typed (not), 105
undeclared, 158, 167
called harmful, 169
undefine, 104, 136
user environment, 368
value, retrieving, 103
visibility (see scope)
where lives, 100
(see also top-level entity)
vector, 237
verb-first dispatch, 477
version (global property), 274
AppleScript, 44
version class, 274
coercion
real, 250
string, 274
comparing version strings, 299
version of software used in this book, xvi
vertical bars (|)
appear spontaneously, 320
in comment delimiters, 89
legalize illegal variable names, 107
prevent terminology clash, 108, 194, 320
record item name (user property), 242
retarget handler call, 194
variable names, 107
visibility (see scope)
vocabulary (see terminology)
volume, mounting shared, 376
volume, sound, 367
Voss, Dustin, 521
W[ Top ]
web server (CGI), 423
web services, 392
WebSTAR event, 423
Wednesday (constant), 277
weekday
coercion, integer, 250
name of, 277
weekday (date property), 224
weeks (global property), 274
"Where is . . . ?" dialog, 387
where keyword, 201
while keyword, 284
white space (constant), 277
whitespace, 83, 84, 226
bytecode decompilation and, 55
changed during decompilation, 54, 85
coercion to zero, 249
ignored when coercing string to number, 249
may follow continuation character, 85
names containing, 107
string comparisons and, 299
whose (synonym for where), 201
Wilde, Ethan, 522
Windows line break (\r\n), 84, 227
Windows shared volumes, 376
with (boolean parameter), 144, 146
with block, 295
with data (make command), 352
with properties (make command), 352
without (boolean parameter), 144, 146
Word, 354, 357, 518
word (string element), 227
workflow, 11
Automator, 32
in Finder contextual menu, 32
in global Script Menu, 32
write command, 371
X[ Top ]
XCMD, 361
Xcode, 441, 516
project, 441
building, 441
interface, designing, 441
Xcode Tools, 441
XML, parsing, 397
XML-RPC, 12, 392-395, 520, 522
Y[ Top ]
year (date property), 224
yes (constant), 276
Z[ Top ]
zones, time, 223, 376
Zurück zu AppleScript: The Definitive Guide