You are on page 1of 6

Envision , Evolve, Unleash

VB Script

Error Handing and Debugging by


Srinivas Malkapeta & Prasanna
Agenda

• Error Handling
Error Handing is the programmer’s line of defense against this
inherent unpredictability.The term error handing refers not only to
how a program responds when an error occurs, but also to how it
prevents errors from happening in the first place.

• Debugging
Debugging, as the name suggests, is the process of detecting,
locating, and removing bugs from a program.
Debugging

The term debugging refers to the activity of a programmer trying to


figure out the cause of a problem (or “bug”) in his or her program,
and then taking steps to eliminate the problem.

What is Debugger?
A debugger is a tool to help programmers follow the logic of their
code as it runs. This can aid not only in finding bugs, but also in
simply understanding a program.

A debugger sits in between the complier and/ or runtime engine and


the actual running program. (In the case of VBScript, the compiling
step is invisible; the scripting engine complies the code for you
when you run it.)
Debugging

A typical debugger gives you various tools to help in watching and


interacting with your code as it executes:

Breakpoints:A way to specify a certain line of code on which to pause


program execution.The line of code you specify is called a breakpoint.

Example: If the problem you are having is deep down the code in your
function, you would mark a certain line in the function as a breakpoint.The
program would run up until the breakpoint is reached, at which point the
program pauses execution, showing you the breakpoint line.

Step Into , Step Over, and Step Out: A way to step through your code one
line at a time.
Debugging

Step Into will bring the debugger into a procedure or function, If one is being called
and if the code for it is in the scope of the debugger.This is useful when you suspect
the procedure being called might have a problem.

Step over:Will do the opposite: If the line you are on calls a procedure or function, the
debugger will execute it without stepping into it.This is useful when you are confident
that the procedure being called is not part of the problem you’re debugging.

Add Watch:A way to view the value of all of the variables active at any given point in
the code.While code execution is paused, mostly any debugger will have some way
to view all of the variables active at that point in the code and what their values
are.(Using Command Widow)

Call Stack:A way to view the “Call Stack” .The Call Stack is the nested sequence of
function and procedure calls that have led to a certain point in the code.Example: The
Call stack displayed the Main procedure which called the sub procedure and also sub
procedure calling to another low-level procedure.
Debugging without Debugger

• Using Global Debug Flag


A global debug Flag is simply a Boolean variable that has global scope in
your script. Once you have defined a global debug flag, anywhere in your
script you can insert code that executes only when the flag is equal to True.
(Step In, Step out & Step Over)

• Outputting Debug Messages


Debug messages can be used many purposes, depending on the
information required, Example : A Log file can be implemented to report all
the significant program events.(Add Watch)

• Inserting Temporary Test Code


If you want to execute test code only while in debug mode.This is especially
useful when you are trying to track down a stubborn logic bug in your
code.(Break points)

You might also like