15.3.1 Displaying Variables in the Watch Window

To add a variable to the Watch window, position the cursor on the variable's name, using the mouse or the direction keys (LEFT, RIGHT, UP, DOWN). Then choose the Add Watch command from the Watch menu, or press CTRL+W.

A dialog box appears with the selected variable's name displayed in the Expression field. If you don't want to watch the variable shown, type in the name of another variable. Click the OK button or press ENTER to add this variable to the Watch window.

The Watch window appears at the top of the screen. Selecting a Watch variable automatically opens the Watch window if the window isn't already open.

A newly added variable may be followed by the message:

<Watch Expression Not in Context>

This message appears when execution has not yet reached the procedure where a local variable is defined. Global variables (those declared outside procedures) never cause CodeView to display this message; they can be watched from anywhere in the program.

To remove a variable from the Watch window, choose the Delete Watch command from the Watch menu or press CTRL+U. Then select the variable to be removed from the list in the dialog box. You can also position the cursor on any line in the Watch window and press CTRL+Y to delete that line.

Summary: You can watch an unlimited number of variables.

You can place as many variables as you like in the Watch window; the quantity is limited only by available memory. You can scroll the Watch window to position it at those variables you want to view. CodeView automatically updates all Watch window variables as the program runs, including those not currently visible within the Watch window frame.

A variable can be specified by its address as well as its name. You can give its address in segment:offset form, where either component can be a register name or a number. You can extract a variable's address by prefixing the & operator to its name. Prefixing a variable's address (or any address) with the BY, WO, or DW operator displays the byte, word, or doubleword value starting at that address.

Summary: There are several ways to display a variable's value.

By default, CodeView displays variables as decimal values. You can select the radix by typing n8, n10, or n16 in the Command window for an octal, decimal, or hexadecimal display. CodeView remembers the current radix when you exit; it becomes the default radix the next time you run CodeView.