I use script libraries all the time. Once you get the hang of it, it becomes a huge timesaver. There are a couple of ways of loading script commands from a “Library Script” into another script.
One way is to use the load script
command by setting a variable name to load script
and path/to/script
.
There is also another way, which in my opinion, is much more powerful. You can import library scripts using the use
statement. This method removes the need of using tell statements
.
For example, I saved your following code as “Hello.scpt” in my /Users/YOUR SHORT NAME/Library/Script Libraries/ folder.
on dialoger(message)
display dialog message
end dialoger
Next, in the script in which I want to load the commands from the Library script “Hello.scpt”, this is the code I used using the use statement
use basescript : script "Hello"
use scripting additions
basescript's dialoger("testing")
By using use statements with multiple applications, you can combine terms from different sources in ways impossible using standard tell statements or tell blocks, because the tell construct only makes one terminology source available at a time.