next up previous contents index
Next: Encrypted Scripts Up: The User Menu: User Previous: Script Menus: User-Defined Sub-Menus   Contents   Index


Script Libraries: Code Sharing

Scripts are executed in Xic using a high-performance compilation technique whereby the entire script is first compiled, then executed. Looping constructs within the script execute very quickly. Further, scripts can call user-defined functions that have been saved in a library, avoiding the tiny compilation overhead and allowing the user to build a collection of sharable function blocks.

Files named ``library'' in the script search path are read and processed when Xic starts, and during a Rehash command. These files should contain function definitions. The functions will be ``compiled'' and saved within Xic. Any executable lines that are not part of a function block will be executed once only as the library is read. This can provide initialization, if needed.

Functions that are saved will be available for calling from scripts, avoiding having to parse them each time the script is run. This also facilitates using the same functions in several scripts.

The functions saved within Xic can be maintained with two `!' commands: !listfuncs provides a pop-up listing of the functions stored, and !rmfunc allows the user to remove functions from memory.


next up previous contents index
Next: Encrypted Scripts Up: The User Menu: User Previous: Script Menus: User-Defined Sub-Menus   Contents   Index
Stephen R. Whiteley 2022-05-28