TatCustomScripter.LoadLibrary Method
Loads and registers a library by name, searching Delphi-based libraries, script-based libraries, and file-based libraries.
Remarks
LoadLibrary loads a library with the name specified by ALibraryName. LoadLibrary is the most generic way to load libraries, since it tries to load different kinds of libraries (Delphi-based libraries, file-based libraries, etc.) given an unique name. When the compiler finds an "uses" clause in the script, it calls LoadLibrary for each "used" unit.
So, calling LoadLibrary "simulates" a unit usage specified in an uses clause. Here is what happens when LoadLibrary is called.
1. Scripter tries to find a Delphi-based library with the name ALibraryName. Delphi-based libraries are those libraries inherited from TatScripterLibrary that were previously registered with RegisterScripterLibrary. The ALibraryName must match the method LibraryName of the registered library. If found, the library is added to scripter with a call to AddLibrary method 2. If Delphi-based library is not found, scripter tries to find a script-based library. It searches for all scripts in the Scripts collection, which UnitName is the same as ALibraryName. If the script is found, then the script is registered as a library. In other words, SelfRegisterAsLibrary is called for that script.
3. If still no library are found, the scripter tries to find a file-based library (if LibOptions.UseScriptFiles is true).
It tries to find a script file which matches the name specified by ALibraryName. See TatCustomScripter.LibOptions property to see the rules for searching the file (search path, default extensions, etc.). If the file is founds, it is loaded in the Scripts collection, compiled (not needed if the file found is already a compiled p-code file), and registered using SelfRegisterAsLibrary method If ADefault is True, the library methods can be called directly from script without using the library name as a prefix.
If no library is found, an exception is raised. If ASilent is True, no exception is raised and nothing happens.
Syntax
Unit: atScript
function TatCustomScripter.LoadLibrary(ALibraryName: string; ADefault: Boolean = True; ASilent: Boolean = False): TatScripterLibrary;
Parameters
| <-> | Parameter | Type | Description |
|---|---|---|---|
| ALibraryName | string | ||
| ADefault | Boolean | Optional: Default value is True |
|
| ASilent | Boolean | Optional: Default value is False |