User's Guide
Did you notice anything wrong with the calculator's behavior? When
you press the Pi button, a new window opens. This is a
Debugger window, which opens automatically in Smalltalk when an error is
encountered.

The top left pane contains a list of current error messages. Right
now there is only one: the phrase item is not valid.
The pane below that is the message stack, sometimes called a
walkback. Each line shows a class name followed by the
method name. This stack traces the execution of code (message sending)
through different classes.
Let's look for the error (if you have not yet done so, press the
Pi button on the calculator to bring up the Debugger):
- Scroll down the message stack and look for the class
STCalculator.
- Select the line that reads STCalculator>>#insert:.
- Note that the text pane displays the source code for the
insert: method. The part of code that was executing
when an error was encountered is highlighted.
- The pane second from the right shows the current variables. In this
case, there is self, which the right pane describes as being an
STCalculator.
- Select aString in the variables pane. You can see in the
right pane that its value is pi. But wait, something is wrong.
The argument aString is supposed to be a string. It looks
like it is a float instead.
- Select the next method down, STCalculator>>#pi. Now you
can see the problem. This method obtains the value of pi from the
Float class, which returns a float. The method
insert:, however, expects a string as the argument.
- You can fix the code here in the Debugger. Edit the text pane to
make the method read:
pi
"The pi button has been pressed. Display its value."
self insert: (Float pi printString)
- Save the method from the Debugger, using the pop-up menu of the text
pane.
- Now go back to the Calculator window and press Pi.
Notice that you can use the same window, and the change is reflected in the
calculator instantly.
- Close the Debugger.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]