Watching value changes
A watch evaluates a Smalltalk expression in the context provided by the stack and displays the result of the evaluation. A watch is useful for tracking changes to a variable's values as you step through code. You can "lock" a watch to a specific stack message and step through code in other stack messages, and still track changes to variable values in the locked message.
To initiate a watch, select a message and a variable; then select Watch from the Inspector menu in the Debugger. (Alternatively, you can select Add Watch from the Watch menu and specify the variable you want watched in the displayed dialog. Or, you can highlight a fragment of Smalltalk code in the description pane and select Watch from the Edit menu.)
For example, to watch how the value for the variable
listBox in
Chooser changes, you can insert a breakpoint after
Stopwatch in the
addApplicationsToList method, evaluate
Chooser new open, and define a watch for
listBox in the debugger. Then, repeatedly press
Over to walk through the code and see how the value for
listBox changes from
nil to
CwList(listBox).
![Watch Watch](../sg/images/tpdebwat.png)
The system updates the information displayed in a watch whenever a new stack message is selected or a step operation is performed. The system traps any compilation or evaluation errors encountered while updating watches and does not generate exceptions.
Last modified date: 03/13/2019