Working with AppleScrpt Libraries|Loading Librareis in a Library

Specific Functions of ModuleLoader

ModuleLoader は、AppleScript Libraries の構文や機能を使わなくても動作します。ModuleLoader 独自の構文を使うことにより、次のModuleLoader 独自の機能を使うことができます。

ModuleLoader can works without syntaxes and functions of AppleScript Libraries. Using own syntax of ModuleLoader, following specific functions are available.

Specifing Loading Libraries

The following is a syntax of AppleScript Libraries to load library "LibraryName" into the property "LibraryName".

use LibraryName : script "LibraryName"

ModuleLoader's following syntax is equivalent to the avobe.

property LibraryName : "@module"

When the value of the property is a string started with "@module", library is loaded into the property. The requested library is indicated by the property name.

By giving a parameter to "@module", the library of which name is diffrent form the property name can be loaded as the following.

property LibraryName : "@module GreatLibrary"

Also version of libraries to load can be specified. See xxx for details.

property SimpleTextLib : "@module"
property _ : script "ModuleLoader"'s setup(me) -- load library at compile-time.

SimpleTextLib's replace_text("How now brown cow", space, "-")
-- result : How-now-brown-cow

Folders to Place Libraries

When a library is specfied with "@module", "Libary/Scripts/Modules" is added to searching location for libraries.

The order to search for library is as the following.

Script files (.scptd, .scpt, .applescript and .app files) as libraries can be placed in following locations.

"Script Libraries" folder is recommend to place library files, because the folder is also used by AppleScript Libraries which has been introduced in OS X 10.9 or later. Only libraries which require ModuleLoader's functions should be placed in "Scripts/Modules" folder.

Loading Source Files, Applets and Droplets

The other advantage of ModuleLoader againt build-in AppleScript Libraries is to load AppleScript souce files (.applescript file), Applets and Droplets which are not works under "AppleScript Libraries".

Therefore following files can be treated as libraries.

Working with AppleScrpt Libraries|Loading Librareis in a Library