Using watch expressions

A watch expression, or watch, is the name of a data element or built-in function whose value appears in the Expressions view. You control the content of the Expressions view by setting watches on those elements that you want to monitor. The values are dynamically updated as you step through the code or as you select different stack trace entries.

You can expand class variables and properties of a class type, as well as arrays, buffers, temp-tables, datasets, and handle variables in the Expressions view. If an object reference or handle has not been initialized, however, you cannot expand it. Arrays, buffers, and temp-tables can be expanded even if they are not initialized.

The Debugger perspective provides several shortcuts for adding watch expressions:

In addition to using these shortcuts, you can right-click in the Expressions view, select Add Watch Expression, and enter an expression directly in the Add Watch Expression dialog. See Expression syntax below.

The Add Watch Expression dialog includes an Enable option, which is checked by default. Deselect this option if you want to add the watch but temporarily make it inactive.

Expression syntax:

Valid watch formats are any of the following:

You can chain attribute references. For example, the following attribute reference displays the value of the TITLE attribute for a window containing a fill-in (assuming the fill-in is three levels from the window):

FILL-IN-1:PARENT:PARENT:PARENT:TITLE:

In addition, the following built-in functions can be watch expressions:

_PCONTROL

_SERIAL-NUM

COM

CURRENT-LANGUAGE

DATASERVERS

DBNAME

ETIME

FRAME-DB

FRAME-FIELD

FRAME-INDEX

FRAME-NAME

FRAME-VALUE

GO-PENDING

LASTKEY

MACHINE-CLASS

MESSAGE-LINES

NUM-ALIASES

NUM-DBS

OPSYS

OS-DRIVES

OS-ERROR

 

PROGRESS

PROMSGS

PROPATH

PROVERSION

RETRY

RETURN-VALUE

SCREEN-LINES

SELF

TIME

TODAY

TRANSACTION

Managing the expression list:

The Expressions view context (right-click) menu includes several commands for modifying or controlling the display. Depending on the element in focus and its context menu options, the commands you see can include the following:

Select All Lets you select all the expressions in the Expressions view.
Copy Expressions Lets you copy one or more expressions.
Remove and Remove All Let you delete expressions.
Find Lets you find an element.
Change Value Lets you enter a new value for an element.
Add Watch Expression Lets you add a watch expression and optionally enable it.
Reevaluate Watch Expression Lets you reevaluate an expression.
Disable and Enable Let you control whether or not selected expressions are updated. You might choose to disable some watches to reduce the time needed to update the Expressions view, or to reduce screen clutter. Watches are enabled by default when you add them.
Edit Watch Expression Lets you change the syntax of the selected expression. You can also toggle its enabled/disabled status.
Create Watch Expression Lets you create a watch expression.