Debug - stepping through a verb
In an earlier section you added a debugging line to a verb definition that allowed you to see the results of intermediate steps when the verb was run. Sometimes you need more powerful tools than that.
Use load to load the debug utilities.
Open your script file cf.ijs and run it.
Let's execute centigrade, but with a stop on each line so that you can take a look at exactly what is going on.
dbss 'centigrade *:*'
The dbss (Set Stop) argument requests a stop before executing all, indicated by *:*, lines in centigrade.
dbr with an argument of 1 requests that the system suspend execution when an error or stop occurs. When a verb is suspended it is halted in mid execution. You can examine definitions, change definitions, and you can resume execution of the suspended verb.
The error report (bars at the left margin) indicates execution stopped on line 0 of centigrade and shows the sentence from that line.
The execution of centigrade is suspended and the indent of six spaces, rather than three, indicates the suspension. The variable y is the argument.
The stop occurs before the line is executed, so t1 has not been defined and if you try to look at it you will get a value error.
Use dbrun to continue execution. It will run the current line, and because stops are set on all lines it will then stop on the next line.
centigrade is now stopped on line 1, and as you can see, you are able to check the value of local t1 that was defined in line 0. Step through the next lines and examine locals.
You are no longer suspended in centigrade and you are back to the normal indent of three spaces.
Turn off the request for debug suspensions and reset to have no stops.