LoadModule

(Engine-Level Function)

Description: Loads a module from its .RUN files and returns a pointer to that module.
Returns: Module
Usage: Script Only.
Function Groups: Compilation and On-Line Modifications,  Advanced Module
Related to: Launch | Thread
Format: LoadModule(FileName, Library, [ModuleName, LoadNow, AppGUID, Reserved, TestCodeLoad])
Parameters:  
FileName  
Required. Any text expression giving the name of the .RUN file from which to load the module.
Library  
Required. Any module value that indicates the library module to which the loaded module will belong.
ModuleName
An optional parameter that is the text expression giving the module's name. This name will then be associated with the module when it is displayed in certain situations, such as in the debugger and the module tree diagram. If this parameter is invalid, the module will appear as "System" when its name is displayed.
LoadNow
An optional parameter that is any logical expression. If true (non-0), the module and its entire sub-tree are loaded immediately. If false (0), the module and its subtree are loaded on demand. The default is false.
AppGUID
An optional parameter that should be included and hold the text GUID of the application when the LoadModule is loading an application.
Reserved
Should be set to Invalid if provided.
TestCodeLoad
An optional parameter that has been reserved for use by the Test Framework to indicate that the LoadModule is loading actual code to be run.
It can contain any Boolean expression that evaluates to TRUE to indicate that the code to run is being loaded.
Comments:

The return value is a pointer to the module. It can be used in a Launch or Thread statement.
The usage of the AppGUID parameter determines how the VTScada engine will treat the module load:

  • If AppGUID is Invalid, this is a "normal" load. No special processing is performed.
  • If AppGUID is a text GUID, the load is a load of the root module for the application. This causes the loading module to become the "namespace root" for the application.

Example:

If ! Valid(CompiledModule);
[
   ExpressionTemplateRUN = RunFileName( FindVariable( "ExpressionTemplate", Self, 0, 0));
   CompiledModule = LoadModule( ExpressionTemplateRUN,  ExpressionParentModule, "Compiled Expression");
]