The Watches window lets you view anything from simple variables to complex expressions. The Watches window is often used as a complement to the Local/Global Variables windows. You can add variables/expressions that you wish to track over the course of the debugging session, or that you wish to find quickly without having to sort through a bigger list in the Local/Global Variables windows.
The Watches window is accessed from the Debug menu by selecting Windows and choosing Watches.
You can add a variable/expression to the watches window by clicking in the Name column of the last empty row, which will open it up for editing, and then type in the name of the variable or the expression and press Enter.
You can also use drag and drop to add watches. Select the desired text from the Code Editor, and drag the text using the mouse to the Watches window and drop it. The selected text will be added to the end of the list of watches.
Watches can also be added from the Local/Global Variables Window as well as the Database Tables Window. Select the specified variable/table column, right-click and select Add to Watches.
To remove a watch, select the item and press Delete.
You can also remove all watches at the same time, right-click in the Watches Window and select Remove All.
Most expressions are evaluated in the debugger, and are available at any time in break mode. But expressions that invoke methods or access object properties, require program intervention and are evaluated in the context of the program. Expressions that require program intervention are not available in limited break mode.
When evaluating expressions that invoke methods or access object properties, side effects can occur. Because the mere evaluation of such expressions may execute code in your program, which can modify variables and the state of your program. Such side effects can make debugging difficult by creating the appearance of bugs or masking real bugs.
Expressions that do not call methods (functions/procedures) cannot cause side effects, because they’re evaluated in the debugger without executing code in the program. Accessing object properties cannot not cause side effects unless the property access method has been explicitly augmented in program code.
Keep in mind that some expressions can be affected by Windows regional settings. For example, if the decimal separator is set to comma, the following expression may be ambiguous:
(Mid("Test",1,1))
To disambiguate the expression, add a space after each comma:
(Mid("Test", 1, 1))
The _wp function is a special debugging function that can be typed as an expression in the Watches Panel to watch the value of a web property. This function will retrieve the web property value without going through the usual error trapping and, therefore, without disturbing your running application.
Struct and Array values are displayed in a hierarchical fashion in the Watches Window. You can expand/collapse the struct members and the array elements.
Values that represent object handles are displayed as integers by default. DataFlex does not have a distinct object handle type.
The Watches window context menu allows you to select any value and choose to display it as an object. If the value corresponds to an object handle in your application, then the value shows a hierarchy of information about the object. You can expand/collapse the tree nodes to reveal the object tree that surrounds the object.
String values are displayed within quotes to make it easier to see leading/trailing whitespace characters. When editing/modifying string variables, the quotes are not displayed and do not need to be specified.
You can modify the value of variables when the program is in break mode. To modify the value of a variable, select the variable in the Watches Window, and then click in the corresponding Value column, type the new value and press Enter.
You can modify the value of most variable types, except for RowID and Variant variables. Variables of String type can be fully modified, including its size, when in normal break mode. While in limited break mode, only the individual characters of String variables can be modified.
sMyVariable
myArray[2]
myUsAddress.sCity
Name(Self)
Value(Self,0)
Field_Current_Value(hDD,iField)
These examples assume that the variables hDD and iField are defined and in-scope.
An expression may contain any valid combination of variables, functions, properties and object functions. Some examples are:
Right(sMyVariable,5)
"Id=" * String(hDD) * Object_Label(hDD)
(_wp(oMyButton, "psCaption"))
This adds the "psCaption" web property to the Watches Panel for a web object named oMyButton. Note that the object is referenced using the object name but the property name is passed as a literal string.