LOADMOD


PLBCMP Only

 

The LOADMOD instruction loads a separately compiled module and links it to the currently executing program. No portion of the just loaded module is actually executed. The instruction uses the following format:

 

 

[label]

LOADMOD

{module}

 

Where:

label

Optional. A Program Execution Label.

module

Required. A previously defined Character String Variable or string Literal containing the name of the module that is executed or a label defined as EXTERNAL.

Flags Affected: NONE

Note the following:

  1. This instruction allows the programmer explicit control over when a separately compiled module is loaded. It is not necessary since any reference to a separately compiled module that has not been loaded will load it automatically at that time. All of the currently unresolved EXTERNAL definitions are resolved that may be resolved.

  2. If the specified module is already loaded, the LOADMOD instruction simply resolves any unresolved EXTERNAL definitions that reference ROUTINEs within the specified module.

  3. This instruction is most useful when the separately compiled subroutine defines global data items that are referenced in the main program or other subroutines. In this case, the global data items must be initialized prior to use and this instruction enables that to occur.

  4. Any separately compiled modules loaded explicitly or implicitly are unloaded when a program chains to another program with the CHAIN, STOP, or DSCNCT instructions. Any global data items that have been defined remain defined in the global data area.

  5. If a module is not be found or there is a problem loading a module, a C15 error occurs.

  6. Common Data is not propagated to LOADMOD modules and does not require data alignment. Any calling routine variables needed in a LOADMOD module should be declared as GLOBAL or passed as arguments to the ROUTINE or PROCEDURE in the module.

 

 

See Also: Example Code, CALL, EXTERNAL, LROUTINE, ROUTINE, XCALL, FUNCTION, LFUNCTION, Program Control Instructions

 



PL/B Language Reference IF,ELSE,ELSE IF,ENDIF LOOP,UNTIL,WHILE,REPEAT