Scripting & Web Development Support

ASP
&
VB


 

Other ASP Commands

CGI/Perl
ASP and VB
Java (JSP)
PHP

 

Description from: http://www.chilisoft.com/caspdoc/

Several additional tools, including form processing, random number generation and checking for existence of a file.

The Tools component creates a Tools object that provides utilities that enable you to easily add sophisticated functionality to your Webpages.

The control makes use of no registry settings.

The Tools component is registered with the ProgId of "MSWC.Tools". The following VBScript excerpt shows creating an instance of the control.

Set oTools = Server.CreateObject( "MSWC.Tools" )

The Tools component exposes the following properties and methods.

There are no properties. 

The methods are:

1. FileExists - Checks for the existence of a file.
2. Owner - Checks if the current user is the site owner.
3. ProcessForm - Processes an HTML form.
4. PluginExists - Checks the existence of a server plug-in (on Macintosh only).
5. Random - Generates a random integer.

 

Method Details

1. The FileExists method checks the existence of a file. It returns -1 if the specified URL exists within a published directory. If the file does not exist, it returns 0.

Arguments:

URL A string that specifies the relative URL of the file you are checking.

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

Example:

The following example demonstrates using the FileExists property to create a link if a particular file is present.

<%If Tools.FileExists("ie_animated.gif") then %>
<p> <a HREF="/isapi/gomscom.asp?
TARGET=/ie/"><img src="ie_animated.gif"></a>
<% End If %>

2. The Owner method: the Chili!Soft implementation of this method always returns 0.

3. The PluginExists method: The Chili!Soft implementation of this method always returns 0.

4. The ProcessForm method processes the contents of a form that has been submitted by a visitor to the Website.

Arguments:

OutputFileURL A string containing the relative URL of the file to which the processed data is written.
 
TemplateURL

A string containing the relative URL of the file that contains the template, or instructions, for processing the data.

InsertionPoint

An optional parameter indicating where in the output file to insert the process data. This parameter has not been implemented. If you include a value for this parameter it will be ignored.

The template files can contain ASP scripts. A script between <% and %> delimiters is treated just like other text in the template and 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 Tools.ProcessForm is executing. Since these scripts are executed before the template data is saved in the output file, the results get saved in the output file, usually as standard text.

The scripts can use any of the ASP intrinsics for the page containing the script executing the ProcessForm method except for the Response objects. Instead the miniscripts have their own Response objects with implementations of Write and BinaryWrite which write to the output file instead of the webserver output stream.

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

If the InsertionPoint parameter does not exist, Tools.ProcessForm replaces the entire output file. If the InsertionPoint parameter exists, and does not begin with an asterisk (*), Tools.ProcessForm finds the InsertionPoint string in the output file and inserts the data immediately after it. If the InsertionPoint string begins with an asterisk (*), Tools.ProcessForm finds the InsertionPoint string in the output file and inserts the data 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.

Example:

The following code demonstrates calling an .asp file to process a form.

<%
Tools.processform("/$Received Messages/default.asp","MessageInsert.process","<SPAN>*") %>

 

5. The Random method returns an integer between -32768 to 32767.

Arguments:

None.

This method is similar to the Rnd function 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:

<% = Tools.Random %> will display a random integer between -32768 to 32767. For example, -13067.
<% = ( Abs( Tools.Random ) ) %> will display a positive random integer. For example, 23054.
<% = ( Abs( Tools.Random ) ) Mod 100 %> will display a random integer between 0 and 99. For example, 63.