Programming Guide : Debugging Your Application : How Debugging an Application Works : How You Can Use the Watch Facility
 
Share this page          
How You Can Use the Watch Facility
The watch facility examines selected local and global variables to determine whether a change in their value has occurred or their specified value has been reached.
Control of execution during the watch state is the same as when the application is running in a normal state except that the Step To End choice is not available. Control can be exercised by selecting Step, Step Into, or Continue while in the watch state of execution.
The watch facility places the Debugger in a watch state whenever there are entries in the Watch window. You can use the Debugger window to examine the value of watch items line by line until one or more of the watch values are reached or a watch change in value is triggered.
The Tools, Watchpoint menu command lets you select a variable as a watchpoint. The value entered for the variable is the watch value. After a watch value is reached, the Debugger is given control at the beginning of the next statement following the one that set the watch value.
While the Debugger has control, you can do the following:
Examine new variables
Enter new watch values
Delete variables from either the Examine window (the data values display area) or the Watch window
Terminate the watch by deleting all of the variables in the Watch window
Execution continues when you again select one of the execution control options.
Set a Watch
You can access the watch facility from the Debugger window.
To access the watch facility
1. Select a variable in the displayed script.
2. Click Tools, Watchpoint, Watch Value, or right-click the highlighted variable to display a pop-up menu and select Watch Value.
The Watch Values dialog appears.
3. Enter the desired watch value, or select the Watch for Change option to start a watch for any change in value.
4. Click OK.
Limit a Watch to the Current Scope
You can limit the watch to the current scope in the Debugger window.
To limit the watch to the current scope
Click Tools, Watchpoint, Watch in Current Scope Only.
Open the Watch Window
You can open the Watch window from the Debugger window.
To open the Watch window
Click Tools, Watchpoint, Open Watch Window.
The Watch window appears to the right of the data value display area in the lower section of the Debugger window.
The watch item is displayed with the value selection. If an asterisk (*) appears in the Value column for the watch variable, any change in value of the variable triggers a break in execution.
Close the Watch Window
You can close the Watch window from the Debugger window.
To close the Watch window
Click Tools, Watchpoint, Close Watch Window, or select a variable and right-click to display a pop-up menu from which you can select Close Watch Window.
Turn Off the Watch Facility
You can turn off the Watch facility from the Debugger window.
To turn off the Watch facility
Click Tools, Watchpoint, Turn Watch Off, or select a variable in the Watch window, and right-click to display a pop-up menu from which you can select Turn Watch Off.