Loading Librareis in a Library|module_loaded_by handler

Specifying Version of a Library

ModuleLoader will load the first existing library matched for specified name. When same name libraries of different versions are installed, you can specify the version of the library to be loaded.

By using a sign of inequality, version specification of ModuleLoader is more flexible than one of AppleScript Libraries.

Giving a Version Number to a Library

A version number can be stored in bundle infomation or in a part of a filename.

Version Setting to a Bundle

A version number can be stored as a value of "Short Version" or "Bundle Version" in bundle information. "Script Editor.app" is useful to edit bundle information as a following image. When both of "Short Version" and "Bundle Version" exists in bundle information, "Short Version" will be preferred.

The "Short Version" and the "Bundle Version" correspond with "CFBundleShortVersionString" and "CFBundleVersion" in "Info.plist" file respectively.

Version Setting in a filename

Also a filename of a library can include the version number. The version number in the filename is connected with "-" after the library name, as following. e.g. "LibraryName-1.2.3.scpt".

LibraryName-VERSION

If a library have version numbers in both of bundle information and the filename, the version number in the filename will be used.

The version number consists of numbers separated by dots. Also one alphabetical character can be placed after the number, e.g. 1.2.3, 0.33.0, 1.0b.

Specifying Version Number of the Library to Load

Use "@version" command after the "@module" command to specify a version number of a library to be loaded as follows

"@module [LibraryName] @version [x.x.x] [>= x.x.x] [> x.x.x] [<= x.x.x] [< x.x.x]"

Square brackets indicate optional arguments. You can specify a library version with not only simple version number of x.x.x but also conditions using sign of inequality. When a sign of inequality is omitted, ">=" is assumed.

The version numbers of loaded libraries are obtained by "module_version_of" handler of the loader script.

property SimpleListLib : "@module @version 1.5" -- same to ">=1.5"
property SimpleListLib_Old : "@module SimpleListLib @version <1.5 >1.0"

tell script "ModuleLoader"
setup(me)
log module_version_of(SimpleListLib) -- 1.5
log module_version_of(SimpleListLib_Old) -- 1.1
end tell

The Order of Priority of Libraries

  1. At first, a library of which filename dose not contain a version number will be searched for. If the library's version match the condition, it will be loaded.
  2. Next, libraries of which filename whose contain version numbers will be checked. A library of the highest version number in the searched folder will be loaded.
Loading Librareis in a Library|module_loaded_by handler