loadjs module_URL [ arguments ]

Scope Available in
immediatetxtmus
abc2svg > 1.23.5

This parameter simplifies the insertion of foreign modules.

In a first step, the javascript code of the foreign module is loaded and compiled aside the txtmus/abc2svg core. When done, in a second step, the main function of this code is called with the current instance of the Mus/Abc object as its first argument. This allows the module to interact with the core, to create new commands/parameters or new entities, and/or to set hooks into the core code.

The name of the main function of the module must be the base name of the module_URL. In case the code of a module is loaded by an external mean, like a javascript file in the command line or a <script src=...> in a HTML file, the module_URL must be reduced to the base file name of the module (name of the main module function).

To simplified the code of such modules, the arguments of the command %%loadjs may be used to set some parameters. When a %%loadjs line is found many times in the music source with the same module, the code of the module is loaded only once, but the arguments may be different (if the module handles this).

Examples:

abc2svg documentation source author - page hosted by Free