5.6 Monitoring the Value of a Variable


As you step through your code using breakpoints in debugging mode, it is useful to monitor the values of variables to locate logic errors in your code. You can check a variable value by placing the mouse pointer over the variable in your source file. The current variable value displays in a pop-up box.

Monitoring Value Of Variable OriginC 91.png

Additionally, Code Builder provides two windows to monitor variable values:

  • The Variables window
  • The Watch window.
Note: The Variables window only displays the values of variables having local scope and consequently does not display the values of LabTalk variables since they have global scope. However, the Watch window displays the values of variables having any scope and consequently does display the values of LabTalk variables.

The Variables Window

The Variables window (View:Local Variables) automatically displays all the variables for the current scope. As you step through the program in debugging mode, the variable values update and the most recently updated variable will be shown in red in Variable window. Arrays, objects and structures can be expanded in the window by clicking on the [+] box.

Scope Variable While Debugging 91.png

The Watch Window

The Watch window (View:Watch) allows you to specify which variables you want to watch the values of in debugging mode. You can add and delete variables to the Watch window while in debugging mode. You can also delete variables from the Watch window when you are not debugging a program.

Similar to the Variables window, the Watch window updates the variable values for the current scope as you step through the program in debug mode. Variables that are not in the current scope will show "Error" for their value.

Adding a Variable to the Watch Window

To specify a variable in the Watch window, first begin debugging. When program execution pauses (either at a breakpoint or at the current line if you pressed ESC), you can then add variables to the Watch window.

Watch Window Debugging 91 01.png

To add a variable, click in the first cell of left column to input variable name and then press ENTER. After pressed ENTER, the variable name, type and value will display in the first line. A second blank line displays beneath your first variable. Repeat the process to add additional variables and the most recently added variable will be shown in red. Arrays, objects, and structures can be expanded in the window by clicking on the [+] box.

Watch Window Debugging 91 03.png

Removing a Variable from the Watch Window

To remove a variable from the Watch window, double-click on the variable name so that the name becomes highlighted in a text box. Press DEL and then press ENTER. This action deletes the variable from the Watch window. You can delete variables from this window which will not affect debugging procedure.