>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Primer

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.
   load 'debug'
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 1
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.
   centigrade 212
¦       t1=.y-32
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.
      dbrun ''
¦       t2=.t1*5
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.
      dbrun ''
¦       t3=.t2%9
      dbrun ''
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.
   dbr 0
   dbss ''

>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Primer