Imports variables and functions from a PSL library.


 requires library ;



name of the library where the specified export variables and functions are to be imported into the PSL program.


The requires statement imports variables and functions identified in export statements from a previously created PSL library into the PSL program. Each requires statement can specify a single library name.

PSL contains no explicit import statement; using the requires statement implies importation. The requires statement searches for the binary containing the library and reads all its export statement information, then imports the specified variables and/or functions into the PSL program.

Any number of requires statements can appear in a PSL program. All libraries specified in requires statements must be available to the compiler during compilation.

requires Statements in Imported Libraries

The PSL compiler automatically resolves nested dependencies in imported libraries, but it will not automatically load all the other exported functions and variables found in the library that satisfies the nested dependency. You must explicitly import a library to guarantee access to all the exported variables and functions within it.

A requires statement can appear inside a function definition without special significance. BMC Software discourages placing export statements inside function definitions and recommends that you place all requires statements at the top of the file.

Best practice

To avoid chains of import dependencies and the possibility of libraries that form requires statement loops, minimize the use of export statements in libraries where the exported variables and functions depend on variables and functions imported with requires statements from other libraries.

Variable and Function Availability Among Imported Libraries

When a PSL program imports variables and functions from more than one library, the imported variables and functions from one library can set and use the imported variables and functions from the others, regardless of how the libraries are loaded for compilation.

BMC Software strongly recommends that you avoid the practice of creating and importing mutually referential libraries. Mutually referential libraries are those that contain a requires statement naming the other library.

Errors Involving the requires Statement

The requires statement can generate compiler errors in the following instances:

  • A reference to an imported variable or function appears before the requires statement that imports it. You must place a requires statement before the first use of the imported variable or function.
  • An imported function has the same name as a function defined within the PSL program.
  • The same variable or function name is imported from two or more libraries.
  • Exported variables are imported into the process that has the requires statement. These variables are not shared between two processes that import the same library.
  • To initialize the exported variables, the library should initialize these variables in an exported function. The process that imports the library must call an exported function to initialize the variables.
export function init_lib_vars() {
app = "My Application";
name = "My Name";
version = 1.5;
requires my_lib;
function print_exported_vars () {
	init_lib_vars(); #initialize value of library variable
print ( "Application: " . app . "\n" ); #use values initiated by library function
print ( "Name: " . name. "\n" );
print ( "Version: " . version . "\n" );

Where to go from here

PSL Statements

Was this page helpful? Yes No Submitting... Thank you