Script Debugger allows parts of a script to be kept in a separate, secondary compiled script file called a library. With a library, your scripts can easily make use of common code. If the code in the library changes, scripts that use the library inherit the changed code automatically when they are compiled.
To work with libraries:
Choose View > Resources Tab.
Or, click Resources in the script window’s toolbar.
The libraries pane appears at the right of the script window.
To add a library file to your script:
If the library file is in your ~/Library/Application Support/Script Debugger 5/Script Libraries folder, click the first Plus button at the bottom of the libraries pane. A pop-up menu appears listing script files in this folder; choose one to add it as a library to your script.
(Option-choose a script file from the pop-up menu to reveal it in the Finder.)
Click the second Plus button at the bottom of the libraries pane. An Open File dialog appears, with which you can choose any script(s) to be added as a library to your script.
To remove a library file from your script:
To determine the reference style for locating a library file in future:
Select the library file in the libraries pane and choose from the Action (gear) pop-up menu at the bottom of the libraries pane:
The way a file is listed to show its path in the libraries pane changes depending on your choice in the Relative To pop-up.
To examine or edit a library file:
To edit the file, double-click its listing in the libraries pane.
To reveal the file in the Finder, Option-double-click its listing in the libraries pane.
The Script Debugger Libraries mechanism may remind you of the AppleScript load script
command, but it has several advantages over load script
:
load script
, the loaded material becomes a script object within your script, whereas with Script Debugger’s library feature, the loaded material is blended with your script.load script
, you have to specify or calculate a pathname in code, whereas Script Debugger helps keep track of libraries for you.Here is some further technical discussion about how the Libraries feature works.
A script that uses Script Debugger’s library feature will run in other contexts — the library resources are invisibly merged into the script when the script is saved, in a way that AppleScript understands — but it cannot be edited except by Script Debugger.
In order to distribute to others a script which uses libraries, in a form that can be edited with any script editor application, you will want to flatten the script. This means that the contents of all library files on which the script depends are visibly incorporated into the contents of the script itself.
To flatten a script:
|