Debugging Options

 

WIL has a some handy debugging capability.

Debug

When Debug is initialized, a dialog box which controls the execution of each statement is displayed. Debug works line by line through the script, displaying the current statement, its value and the following statement. The script will also be executed in conjunction with the display of statements. Initialize Debug by adding Debug(1) or Debug(@ON) to a specific point in your script.

DebugTrace

DebugTrace will create a file showing each line executed and the return value of the line.  It will consume considerable processing time and is generally reserved for particularly hard-to-debug problems. DebugTrace will append the debug data to the end of the file you specify. You may want to delete the file, if it already exists.

To debug into a 'Called' WinBatch script, User Defined Function or User Defined Subroutine, make sure to add the corresponding DebugTrace command, to the 'called script', User Defined Function or User Defined Subroutine.

; DebugTrace(22) allows DebugTrace continuation (inherit the debug mode from the caller).
; By default, when the code enters a UDF, UDS or Call'ed script file, statement by statement
; debugging is suppressed until the script returns. Adding DebugTrace(22) to a UDF, UDS, or
; called script will resume statement by statement debugging *IF* it was active on entry.
#DefineFunction SampleOne()
   DebugTrace(22)
   b = 1
   Return b
#EndFunction

#DefineFunction SampleTwo() DebugTrace(22) c = 1 Return c #EndFunction
DebugTrace(@on,DirScript():"trace.txt") a = 1 b = SampleOne() c = SampleTwo() ShellExecute(DirScript():"trace.txt", "", "", @normal, "") Exit

DebugData

DebugData writes data via the Windows OutputDebugString function to the default destination.  The function is generally only useful if you have the proper tools and hardware to debug Windows applications.  In general, for standard retail Windows, the default destination is COM1.  The Windows SDK provides tools (DBWIN) to allow you to capture the debug data to an alternate device or to a special window.

Use of this function in standard retail Windows may interfere with any device, such as a mouse or modem connected to COM1.

For users without sophisticated (and expensive) debugging tools, the WIL Debug, DebugTrace  or the Message function work incredibly well.

Message or Pause

Properly placed Message or Pause statements can be used sporadically through out the script to display values of variables.

 

 

§         Notes

§         Reference

§         Step by step guide to learning WIL