Using Terms From

A terms block has the following structure:

using terms from application
    -- code containing terms to be resolved
end using terms from

A terms block dictates which application’s dictionary AppleScript should get the enclosed terminology from, without actually targeting that application. Terminology is resolved at compile time; therefore the application must be a literal application specifier (otherwise there’s a compile-time error, “Can’t make some data into the expected type”). A terms block is important only at compile time (and decompile time); it is effectively ignored at runtime.

A question immediately arises of what happens when a tell block and a terms block are nested inside one another. The short answer is that the innermost block takes precedence. Here’s an example of how to screw things up:

tell application "Finder"
    using terms from application "Microsoft Entourage"
        get name of folder 1 -- error: Finder got an error: Can't get name of folder 1
    end using terms from
end tell

The problem there is that you’re forcing AppleScript to resolve folder by means of Entourage’s dictionary. Entourage defines folder, but using a different four-letter code from the Finder. You’re still targeting the Finder, though, so when you do, you’re talking to it in Entourage’s language, which the Finder doesn’t understand.

But if an innermost tell block would not permit AppleScript to resolve terminology, a terms block surrounding it may do so. This will compile just fine:

using terms ...

Get AppleScript: The Definitive Guide, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.