Debugging Scripting Code
A common feature of integrated development environments is the ability to debug the code you have written. Debugging programming code involves choosing to debug when a script error occurs or setting a breakpoint in the code that tells the debugger when to suspend program execution, which allows developers to step through their code and examine its behavior. However, when debugging script for an InfoPath form, breakpoints are not recognized. Instead of breakpoints, you must use the JScript debugger statement or the VBScript Stop statement to stop code execution for debugging purposes.
After you have entered a debug statement in your code, save the code and preview your form. The following example demonstrates how to use the debug statement in the OnLoad event handler using JScript syntax:
When you preview or open a form that has a debug statement in it, the Just-In-Time Debugging dialog box appears, prompting you to select the debugger that you want to use. If Microsoft Script Editor is still open, select Microsoft Script Editor [design], otherwise click New Instance of Microsoft Script Editor, and then click Yes. Microsoft Script Editor opens in debug mode and displays a yellow arrow indicating where program execution has been suspended. Press F10 to move through the remaining lines of code in the script.
To stop debugging your scripting code, click Stop Debugging on the Debug menu, or press SHIFT+F5 .
|If Microsoft Scripting Editor is not available when the Just-In-Time Debugging dialog box appears, or the Just-In-Time Debugging dialog box is not displayed when you preview your form, you need to install the Web Debugging feature as described in the following steps.|
- In Control Panel, select Add or Remove Programs (Windows) or Programs and Features (Vista).
- Select Microsoft Office in the list of installed programs, and then click Change.
- Select Add or Remove Features, and then click Continue.
- Expand the Office Tools, Microsoft Script Editor (HTML Source Editing), and Web Scripting folders.
- Click Web Debugging, and then click Run from My Computer.
- Click Continue.