Skip to main content

AppleScript

AppleScript has been in use for decades, and with such usage comes a large back catalog of existing code. Through an AppleEvent-based AppleScript FFI, BushelScript scripts can use this code, too.

If you find yourself calling AppleScript because of a deficiency in BushelScript's AppleEvent functionality, please file a bug report describing how BushelScript could be improved. Thanks!

Importing scripts#

AppleScript scripts can be imported as AppleScript resources.

Terminology#

When an imported script defines terminology in an sdef file, its resource term contains and exports it. This is usually the case for AppleScript libraries.

Calling handlers#

Handlers are functions written in AppleScript which are callable through in-process AppleEvents. AppleScript handlers can thus be called from BushelScript through remote calls with the AppleEvent descriptor transport format.

With command terms#

A handler for which a command term is defined can be invoked like any other command. This is typically the case with AppleScript libraries.

Via user-defined identifiers#

Handlers named using AppleScript user-defined identifiers (green text in Script Editor) are not automatically imported as terms into BushelScript, but are still accessible through raw form terms with the asid semantic URI scheme.

require AppleScript My Script at "~/Scripts/My Script.scpt"
tell My Script
-- Calls a handler named with the
-- user-defined identifier "my_applescript_handler"
#command [asid:my_applescript_handler]
end tell
Last updated on by Ian Gregory