12.14.8    Display errors (Debug a JScript)

Debug JScript Example.

This script is used to debug an JScript and print errors to BWSPOOL message window. You to enter the name of the Script to be tested in a Text-type tag named TestScriptname. Note that ACTION commands do not usually return errors.  The catch commands displays errors by the JScript KEYWORD commands. Note that a JScript can debug only another VB Script. A JScript can not debug Tcl Script or VB Script.
The Tcl Script version is at 12.10.8 Display errors (Debug a Tcl Script).
The VB Script version is at 12.17.8 Display errors (Debug a VB Script).


// DebugJScript.js - a JScript

// open the spooler window to print the file


BWSPOOL("\r\n");  //print a carriage return and line feed

var e, fso, f, s, filespec, ForReading;

ForReading = 1, s = "", e = "No reported errors.";

// get the name of the file to run from a text tag

   filespec = GETVAL("TestScriptname");

// Run the script and catch any errors.

try {


     BWSPOOL("Try to run ");



     // Test if it exists

      s = filespec;

      fso = new ActiveXObject("Scripting.FileSystemObject");

      if (fso.FileExists(filespec)) {

        s += " found.";




         s += " file not found.";

         e = " file not found.";




} catch (e) {

     // print any errors


} finally {


if (e == "No reported errors.")



/* The FileExists method is at

MSDN Home >  MSDN Library >  Web Development >  Scripting >  Windows Script Technologies >  Script Runtime >  FileSystemObject Object >  Reference >  Methods


The Try Catch is at

MSDN Home >  MSDN Library >  Web Development >  Scripting >  Windows Script Technologies >  JScript >  Reference >  Statements



The Tcl version is at 12.10.8 Display_errors(Debug_a_Tcl Script)