A collection of AppleScript libraries to make up for missing standard functionality. Currently the following libraries are available:
There are different ways libraries can be used to speed up scripting with AppleScript. This website provides some libraries for common everyday problems. Libraries can easily be included into your script.
This example will use the replaceString handler of the String Library. First download the entire library, unzip the archive and move the extracted file '_script.scpt' to the desktop. If you want, open the scpt-file in AppleScript-Editor. It contains the same information as shown on the String Library website.
Next, open a new empty document in AppleScript Editor. Loading an AppleScript library is easy:
set _string to load script alias ((path to desktop as text) & "_string.scpt")
The string library is now ready for use. There are various ways of calling a handler within a library. To demonstrate them, let's introduce some silly string:
set str to "This is a test!"
Personally, I prefer and recommend the 'genitiv'-like syntax since it doesn't require a whole lot of code:
set resultOne to _string's replaceString(str, "test", "cat") --> "This is a cat!"
The second alternative is using the 'genitiv'-like syntax with the 'of'-keyword:
set resultTwo to replaceString(str, "test", "dog") of _string --> "This is a dog!"
Last but not least you may also use the well-known 'tell'-syntax. In my opinion, this is not a good way since it requires too much additional unnecessary code:
tell _string
set resultThree to replaceString(str, "test", "monkey") --> "This is a monkey!"
end tell
tell _string to set resultFour to replaceString(str, "test", "rat") --> "This is a rat!"
That's it! That's pretty much all you need to know to work with AppleScript libraries.
You can download this short example or open it directly in AppleScript Editor.
Obviously not all of the functions and handlers found on this site were written by myself. Credits go out to the following websites:
HAS | appleMods
Aurelio.net
hohabadu.de
Mac OS X Automation
Piero Garzotto