%@ LANGUAGE = JScript %>
Tools Component
Tools Component
<%
var Tools;
var FoundFile, FileExists, FileDoesNotExist, NotFoundFile;
var RandInt, RandPosInt, RandIntBelow;
Tools = Server.CreateObject("MSWC.Tools");
%>
FileExists Example
<%
FoundFile = "Tools_VBScript.asp";
NotFoundFile = "blah.asp";
// Check if file exists
FileExists = Tools.FileExists(FoundFile);
// Output Response Appropriately
if (FileExists == true)
{
Response.Write("The File " + FoundFile + " Exists
");
}
else
{
Response.Write("The File " + FoundFile + " Does Not Exist
");
}
// Check if file exists
FileDoesNotExist = Tools.FileExists(NotFoundFile);
// Output Response Appropriately
if (FileDoesNotExist == true)
{
Response.Write("The File " + NotFoundFile + " Exists");
}
else
{
Response.Write("The File " + NotFoundFile + " Does Not Exist");
}
%>
Random Integer Example
<%
// Random Integer
RandInt = Tools.Random();
Response.Write("Random integer: ");
Response.Write(RandInt);
Response.Write("
");
// Positive Random Integer
RandPosInt = Math.abs( Tools.Random() );
Response.Write("Positive random integer: ");
Response.Write(RandPosInt);
Response.Write("
");
// Positive Random Integer between 0 and 100
RandIntBelow = Math.abs( Tools.Random() ) % 100;
Response.Write("Random integer below 100: ");
Response.Write(RandIntBelow);
Response.Write("
");
%>