Debugging your code

You can debug your schema customization effort from within HCL Compass using a number of different utilities. One common method is to output text at strategic locations in the code, using MsgBox or OutputDebugString.

  • MsgBox

    This function is available on Windows only.

    The MsgBox function lets you place a Windows Message Box on the screen with the output you specify. The execution of the hook pauses until the OK button on the Box is clicked (for example: MsgBox "My Text." ). The message box only displays where the hook is executed.

    When writing VBScript hooks, you can use the message box (MsgBox) function to output debugging information. By calling this utility with a string parameter, a popup dialog containing the text is displayed. You can use MsgBox in Perl with the following syntax:
    eval("use Win32; Win32::MsgBox('called from Perl')");
    Note: Do not invoke this utility through Compass Web. If you use the MsgBox function, you can ensure that your code is not executed in a Web session context with the _CQ_WEB_SESSION session variable. See "Using hooks to detect a Web session".
  • DBWIN32

    The Windows debugging utility dbwin32.exe is included with HCL Compass for Windows® client. It is located in the HCL Compass installation directory. When dbwin32.exe is active, it displays all messages generated by the OutputDebugString method of the Session Object, which you can use to output debugging messages from a hook while it is running. By calling the OutputDebugString method, the related debug statements appear in the DBWin32 console, along with any configured tracing information. Use this method after launching DBWin32 to see messages.

  • HCL Compass Designer hook compiler

    This utility catches some syntax errors.

  • Internet Explorer debugger (Windows only)

    You can use the Internet Explorer debugger to debug your VBScript hook code. You can download and install this debugger at the following address:

    http://msdn.microsoft.com/scripting > Script Debugger

    A hook runtime error launches the debugger (if it is not launched, you will need to read the debugger documentation). To force the debugger to be launched, add a stop statement to your VBScript hook code, and the debugger launches at that point.

  • Microsoft Development Studio VBScript debugger

    General debugging of VBScript hooks can be done with the Microsoft VBScript Debugger. If you have Microsoft Visual Studio installed, you can use its VBScript debugger to debug your hook code.