VBScript Debug Objects

Advertisements


What are Debug Objects?

The Debug Objects are global objects that can send output to a script debugger. Here, the debugger what we refer to is Microsoft Script Debugger.

The Debug objects cannot be created like other objects but can be used when we are debugging.

The following methods are supported by Debug Objects. These methods or objects have no effect if the script is NOT executed in debug mode. The Methods supported by Debug Objects are discussed in detail.

Write

The Write method sends strings to the immediate window of the Microsoft Script Debugger at run-time. If the script is not executed in debug mode, then the Write method has no effect.

Write Debug.Write([str1 [, str2 [, ... [, strN]]]])

Example :

<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">

 Dim counter
 counter = 42
 Debug.Write "The value of counter is " & counter
 
</script>
</body>
</html>

WriteLine

The Writeline method is very similar to Write method. The WriteLine method sends strings, followed by a newline character, to the immediate window of the Microsoft Script Debugger at run time. If the script is not executed in debug mode, then the WriteLine method has no effect.

Debug.WriteLine([str1 [, str2 [, ... [, strN]]]])

Example :

<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">

  Dim counter
  counter = 42
  Debug.WriteLine "The value of counter is " & counter
 
</script>
</body>
</html>

Enabling Debug Mode :

To enable script in debug mode, following actions to be performed by the user:

  1. On the Tools menu, click Internet Options.

  2. In the Internet Options dialog box, click the Advanced tab.

  3. In the Browsing category, clear the Disable script debugging check box.

  4. Click OK.

  5. Exit and restart Internet Explorer.



Advertisements
Advertisements