In some cases, you may want to access functionality provided in another module, and in manu cases this is an optional, rather than core, module. If you call an function in another module that does not exist, you will get an error for the user and a Trace file. This code snippet provides a method so you can test if a module is installed on a server prior to calling it withing your code. The code for this function is as follows :
// This function returns TRUE if the specified module is loaded, and FALSE otherwise
function Boolean isAModule (string moduleName)
dynamic module=$Kernel.ModuleSubsystem.GetItem(moduleName)
// if the module is loaded
if (IsDefined(module))
return true
else
return false
end
end
The following code snippet shows how you could use this function to test if the Directory Services module (module name
directory) is installed on the server, assuming that the function is in the same Object or Request Handler as the calling function :
if (.isAModule("directory"))
echo("Directory module installed")
else
echo("Directory module NOT installed")
end