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

WINEXEC("BWSPOOL.EXE");

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 {

     SCREXEC(filespec);

     BWSPOOL("Try to run ");

     BWSPOOL(filespec);

     BWSPOOL("\r\n");

     // Test if it exists

      s = filespec;

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

      if (fso.FileExists(filespec)) {

        s += " found.";

      }

      else

      {

         s += " file not found.";

         e = " file not found.";

      }   

     BWSPOOL(s);

     BWSPOOL("\r\n");

} catch (e) {

     // print any errors

     BWSPOOL(e);

} finally {

}

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

 BWSPOOL(e);

 

/* The FileExists method is at

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

http://msdn.microsoft.com/library/en-us/script56/html/jsmthFileExists.asp

The Try Catch is at

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

http://msdn.microsoft.com/library/en-us/script56/html/js56jsstmtrycatch.asp

*/

The Tcl version is at 12.10.8 Display_errors(Debug_a_Tcl Script)