Scripting Additions Guide
Table Of Contents
CHAPTER 3
Writing Scripting Additions
Using Other Resources With Scripting Additions 91
Using Other Resources With Scripting Additions 0
The scripting addition loading mechanism adds the invoked scripting
addition’s resource file to the top of the target application’s resource chain.
This guarantees that resources in the scripting addition’s resource file will
be found before resources with the same name or ID in the application or
system resource files. For example, in the following script, the resource chain is:
Beep scripting addition -> MyApplication -> System file (assuming
MyApplication hasn’t added anything else to the chain).
tell application "MyApplication"
beep 3
end tell
If a scripting addition is called outside of a Tell statement, the resource chain is
the same as just described, except that the application is the application
running the script (for example, Script Editor).
Using Records for Scripting Addition Reply Values 0
Some scripting additions return more than one piece of data in their replies. If a
scripting addition returns a list, it can refer to the elements of the list by index.
But if a scripting addition returns a record with named fields, it cannot refer to
the items in the record by their names, because although an 'aete' resource
allows you to specify the type of a return value, it does not provide any
additional information about it, such as the names of its fields if it is a record.
If you need that additional information, you can create a new class that has
properties for each of the fields in the record, and you can then declare the
return type of the reply to be the ID of this new class.
Listing 3-2 shows an 'aete' code excerpt that defines a class with the ID
'hack'. This code is placed in the return type field of the event’s reply. The
property IDs are the keywords for the record’s fields.