module_loaded_by handler|ModuleLoader Reference

Making a Location of Libraries for a Project

Shared libraries between some projects should be placed in "Library/Script libraries" or "Library/Scripts/Modules". A location for libraries which are used only for a certain project may be required. If you make a "local loader applet", you can make a location for libraries for a ceratin project.

At first, you should make a folder to place libraries for the project. And save the following script as an applet i.e. this applet is the local loader applet.

property parent : script "ModuleLoader"'s local_loader()

The options when saving the local loader applet must be as follows.

Then place libraries for the project at the same location to the local loader applet.

To load the libraries which located with the local loader applet, obtain a loader script from the local loader applet by calling "loader()" handler, and call "setup" handler as follows.

property LibForLocalLoader : "@module"
property _ : application (get "SampleLocalLoader")'s loader()'s setup(me)

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

You can take is easy to change the loation of the library by indicating the location with a local loader applet instead of a path string.

Local Loader Options

You can customize behavior of the local loader using special properties. These properties must be defined before calling "setup" handler of the loader script.

property LibForLocalLoader : "@module"
(* making alias files of loade libraries under the folder Local Loader applet is in *)
property _collecting_modules_ : true
(* find libraries only from the folder the Local Loader applet is in *)
property _only_local_ : true

application (get "SampleLocalLoader")'s loader()'s setup(me)

_collecting_modules_

When true is given, alias files of libraries loaded from "Library/Scripts Libraries" folder or "Library/Scripts/Modules" folder will be created in the location the Local Loader applet is in. This function is useful to collect used libraries into the one place.

The default value is false.

_only_local_

When true is given, locations to search for libraries are restricted to the location the Local Loader applet is in. The default value is false.

If _collecting_modules_ is true, _only_local_ will be ignored.

module_loaded_by handler|ModuleLoader Reference