Line Numbers on Library Reference Source Code [Adv3/Adv3Lite]

I’ll also point out that doing this (displaying the line of source that threw an exception plus a couple lines of context) is one of the design use cases for the interative-ish debugger. I posted last week.

It’s a little fiddly because T3 doesn’t consistently prefer full vs relative paths and by default some intepreters (like FrobTADS’ frob, which is what I’ve been using by default during development) will default to only allowing the interpreter to read files from the directory the game file was loaded from. But with a little tweaking you can get a workflow where you can do something like:

# t3make -d -a -f catch.t3m
     [compile output]
# frob gates/catch.t3
Void
This is a featureless void.

You see a pebble here.

>take pebble
[Runtime error: invalid datatypes for addition operator
->pebble.actionDobjTake() src/catch.t, line 65
   {obj:predicate(Take)}.execAction()
   [rest of stack trace snipped]
===breakpoint in pebble.actionDobjTake() src/catch.t, line 65===
===type HELP or ? for information on the interactive debugger===
>>> list
 060
 061   dobjFor(Take) {
 062       // This since foozle is nil, this will throw a runtime
 063       // error, dropping us into the debugger.
 064       action() {
>065           foozle += 1;
 066           inherited();
 067       }
 068   }
 069 ;
 070
>>> 

It doesn’t have anything like a full source navigator, no integrated editor, and you can’t do stepwise execution. So it’s definitely just a big ol’ ugly kludge, not a proper interactive debugger. But the first thing I want to do after the interpreter barfs is to look at the source that threw the exception, and this does that.

1 Like