1.5 Exercise 5: Debugging

In this exercise we will take a brief look at how the Mjolner tool can help you locate errors in your programs.

Load the file syntaxedit.bet.

Compile [505 bytes 32x18 PNG] and run [637 bytes 32x18 PNG] the program. It contains a 'Reference is none'-error.

Click the Debug button [569 bytes 32x18 PNG] in the toolbar or right click in the code and choose 'Compile/Run->Debug syntaxedit'. Now a debugging window pops up.

1.5.1 Reference is none

Click 'Go' in the debugging window. This time, when the program stops, the window tells you at the bottom that there is an error: 'Reference is none'. And in the Form window the command causing the error is marked ('kg'->value, which should be 'kg'->value[]). Close the debugging window, correct the error and run the program again.

It is that easy to find and correct errors like 'Reference is none'!

1.5.2 Break points

For practice we will insert a breakpoint at 'The car is:'->putline. Mark this line and right click. Choose 'Set Break' and mark something else (anything).

Click 'Go' in the debugging window. Now the program runs for a little while and then stops at the break point.

Click the Object button in the debugging window. This displays the active object, i.e. the object whose do-part is currently being executed. Here, the active object is of course the entire program.

You can see that the object has a component called aPerson which is an instance of the program.Person pattern. But we already knew that. Now double click that line. Double click Name, and double click T. You can see that the person is Santa Claus.

In this manner the object structure can be observed at runtime. Sometimes this is preferable to inserting debug-printlines.

Now click the break point <<1>>, then right click and choose 'Erase Break'. Choose 'Rerun' either from the right click menu or the new window. Now the program is ready to start over.


Mjolner Tool Workshop
© 2001-2002 Mjølner Informatics
[Modified: Wednesday September 12th 2001 at 17:10]