Loading Scripting Additions

To be usable, a scripting addition must be present in the correct location on the machine where a script will compile or run. This means that scripts relying on third-party scripting additions are not particularly portable. You might write a script that depends on some scripting addition, and then distribute it to others without remembering to provide the scripting addition on which it depends. This can easily happen by accident, because scripting addition terminology appears to you, the programmer, to be part of the AppleScript language. Once again, Script Debugger is especially helpful here; it can list the scripting additions on which your script depends, and will even look them up on http://macscripter.net for you.

You might provide, along with your script, any third-party scripting additions on which the script depends. Two problems then remain:

  • Osaxen are not loaded from just any old location; to be seen at all, they must be in a Library/ScriptingAdditions folder.

  • Osaxen are loaded when the AppleScript scripting component instance is created and starts up.

So the user must install the extra scripting additions in the correct place before running your script. A script might, at runtime, move a scripting addition file into a ScriptingAdditions folder, but it’s too late, since the AppleScript scripting component instance has already been created, and any scripting additions that are going to be loaded have already been loaded.

Under Mac OS X 10.3 (“Panther”), ...

Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.