12.8 Tools

The Tools component provides the ability to add sophisticated functionality, such as generating random numbers, checking whether a particular server plug-in exists, processing the contents of an HTML form, etc., to the Web page.

12.8.1 Object Diagram

Describes  the hierarchy of various objects in the Tools component

12.8.2 Tools Object

Provides the ability to add sophisticated features, such as generating random numbers, checking whether a particular server plug-in exists, processing the contents of an HTML form, etc., to the Web page.

12.8.3 FileExists method

Checks the existence of the specified file. Returns TRUE if the file exists.

Syntax

 object.FileExists(
   URL As String)
 

Parameters

URL
Specifies the relative URL of the file whose existence has to be checked.

Return Values

Boolean.

Remarks

FileExists checks only the existence of files published on your site. Therefore, it takes a relative URL rather than an absolute URL.

Example

This example returns TRUE if MYHOME.HTM exists in the directory specified.

 <% Set Tools = CreateObject ("MSWC.Tools") 
   File = Tools.FileExists("/bin/mypages/myhome.htm")  
 print File %> 
 

12.8.4 Owner method

Checks if the current user is the owner of the directory where the current page is located. It returns TRUE if the user's name submitted in the process form matches that of the owner's.

Syntax

 object.Owner()
 

Parameters

None.

Return Values

Boolean.

Example

This example demonstrates the owner method.

 <% Set Tools = CreateObject ("MSWC.Tools") 
   owner = Tools.Owner()  
 print owner %> 
 

12.8.5 PluginExists method

Checks if the specified server plug-in is registered. It returns TRUE if it is currently registered.

Syntax

 object.PluginExists(
    PluginName As String)
 

Parameters

PluginName
Specifies the name of the server plug-in.

Return Values

Boolean.

Example

This example returns TRUE if the specified plug-in exists on the server.

 <% Set Tools = CreateObject ("MSWC.Tools") 
   plugin = Tools.PluginExists("RealPlay.exe")  
 print plugin %> 
 

12.8.6 ProcessForm method

Processes the contents of a form that has been submitted by a visitor to the Web site.

Syntax

 object.ProcessForm(
    OutputFileURL As String,
    TemplateURL As String
    [, InsertionPoint As String])
 

Parameters

OutputFileURL
Name, with the relative URL of the file to which the processed data is written.
TemplateURL
Name, with the relative URL of the file that contains the instructions for processing the data.

The template files can contain ASP scripts. A script between <% and %> delimiters is treated just like other text in the template and is copied into the output file. If the output file is an ASP document, the script will run when the output file is accessed. Scripts in template files can also be put between special <%% and %%> delimiters which cause the script to execute while ProcessForm method is executing. Since these scripts are executed before the template data is saved in the output file, the results are saved in the output file, usually as standard text.

InsertionPoint
This is an optional parameter. Specifies where in the output file the data should be inserted.

If the InsertionPoint is not specified, the entire output file is replaced with the data.

If it exists and does not begin with an asterisk (*), the ProcessForm method finds the insertion string in the output file and places the output immediately after it. If it exists and begins with an asterisk (*), the output is placed immediately before it.

If the InsertionPoint string exists, but is not found in the output file, the data is appended to the end of the file.

Return Values

Null.

Remarks

If the output file does not exist, the server creates it.

Example

This example demonstrates the ProcessForm method.

 <%
 Tools.ProcessForm("/Novell_home/sales/result.htm","salesprocess.asp","*Order") 
 %>
 

12.8.7 Random method

Returns an integer between -32768 and 32767.

Syntax

 object.Random()
 

Parameters

None.

Return Values

Integer.

Remarks

This method is similar to the Rnd function of C language but returns an integer. To get a positive random integer, use the Abs function. To get a random integer below a specific value, use the Mod function.

Example

This example generates a random number, gives its absolute value, and the modulus value within 200.

 <% = Tools.Random %> will display a random integer between
 -32768 and 32767. For example, -27436.
 <% = ( Abs( Tools                                                                               .Random ) ) %> will display a positive random integer. For example, 27436.
 <% = ( Tools.Random ) Mod 200 %> will display a random integer between -199 and 199. For example, 196 %>