9.10 Modules Collection

Features:

9.10.1 Element method

Finds an NLM in the collection.

Syntax

object.Element( 
   ModuleName As String)

Parameters

ModuleName

The name of the NLM to find. You can optionally specify the object's full path.

Return Values

Module.

Remarks

If the module is not found, the method returns the value NULL. If the full path is specified along with the name of the module, the NLM header is read from the corresponding NLM file and a Module object is returned.

Example

This example returns the Module object calnlm32.nlm.

’Find a Module object corresponding to calnlm32 
’Print the copyright information of calnlm32 
set srv = createobject ("ucx:Server") 
set modules = srv.modules 
set module = Modules.element("calnlm32.nlm") 
print ("Copyright of calnlm32 is " &Module.copyright) 

9.10.2 HasMoreElements method

Determines whether or not any more NLMs exist in the collection.

Syntax

object.HasMoreElements()

Parameters

None.

Return Values

Boolean. Returns TRUE if more NLMs exist in the collection; otherwise, FALSE.

Example

This example determines whether or not any more NLMs exist in the collection.

’Reset the collection and list all the loaded NLMs 
set srv = createobject ("ucx:Server") 
set modules = srv.modules 
Modules.reset() 
while (Modules.hasmoreelements()) 
     set module=Modules.next() 
     print (Module.name) 
wend 

9.10.3 Load method

Loads an NLM.

Syntax

object.Load( 
   ModuleName As String)

Parameters

ModuleName

The name of the NLM to load. You can optionally specify the full path of the NLM file. This parameter can contain the entire command line option, including the arguments.

Return Values

Boolean. Returns TRUE if the NLM is successfully loaded; otherwise, FALSE.

Remarks

If the Web-based script is not authenticated to eDirectory with appropriate rights, an error is returned.

Example

This example loads the NDS API NLM.

’Load DSAPI.NLM 
set srv = createobject ("ucx:Server") 
set modules = srv.modules 
if (Modules.load ("dsapi.nlm")) then 
     Print ("NDS API NLM is loaded") 
else 
     Print ("Failed to load NDS API NLM ") 
end if

9.10.4 Loaded method

Determines whether or not an NLM is already loaded.

Syntax

object.Loaded( 
   ModuleName As String)

Parameters

ModuleName

The name of the NLM. You can optionally specify the object's full path.

Return Values

Boolean. Returns TRUE if the NLM is already loaded; otherwise, FALSE.

Example

This example determines whether or not dsapi.nlm is already loaded. If it is not, the Load property will load it.

’Verify whether or not dsapi.nlm is already loaded 
’If not, load dsapi.nlm 
set srv = createobject ("ucx:Server") 
set modules = srv.modules 
if (Modules.loaded ("dsapi.nlm")) then 
     Print ("NDS API NLM is loaded") 
else 
     Print ("Loading NDS API NLM ") 
     Modules.Load ("dsapi.nlm") 
end if

9.10.5 Next method

Returns the next NLM in the collection.

Syntax

object.Next()

Parameters

None.

Return Values

Module. Returns NULL if the collection has no more elements.

Example

This example returns the next NLM in the collection.

’Reset the collection and list all the loaded NLMs 
set srv = createobject ("ucx:Server") 
set modules = srv.modules 
Modules.reset() 
while (Modules.hasmoreelements()) 
     set module=Modules.next() 
     print (Module.name) 
wend 

9.10.6 Replace method

Updates an NLM by replacing an old version with a new version.

Syntax

object.Replace( 
   OldNLM As String, 
   NewNLM As String)

Parameters

OldNLM

The full path of the existing NLM file.

NewNLM

The full path of the new NLM file.

Return Values

Boolean. Returns TRUE if the NLM is replaced; otherwise, FALSE.

Example

This example updates the test.nlm file by replacing the old version (sys:system\test.nlm) with the new version (sys:temp\test.nlm).

’Replace the old version of test.nlm with the new version of test.nlm 
set server = CreateObject ("ucx:Server") 
set modules = server.Modules 
if (Modules.Replace ("sys:system\test.nlm", "sys:temp\test.nlm")) then 
     print ("Replaced Test.nlm ") 
else 
     print ("Failed to replace Test.nlm ") 
end if

9.10.7 Reset method

Resets the collection and starts an iteration.

Syntax

object.Reset()

Parameters

None.

Return Values

Void.

Example

This example resets the collection and starts an iteration.

’Reset the collection and list all the loaded NLMs 
set srv = createobject ("ucx:Server") 
set modules = srv.modules 
Modules.reset() 
while (Modules.hasmoreelements()) 
     set module=Modules.next() 
     print (Module.name) 
wend