NB. debug names
NB.
NB. e.g.  dbss 'f 0'   monadic line 0
NB.       dbss 'f :2'  dyadic line 2
NB.       dbss 'f *:*' all lines
NB.       dbss '* *:*' all names, all lines
NB. 
NB. The call stack (dbstk'') is an 8-column boxed matrix:
NB.   0  name
NB.   1  error number, or 0 if this call is not erroneous
NB.   2  line number
NB.   3  name class
NB.   4  definition
NB.   5  source script
NB.   6  argument list
NB.   7  locals

t=. 'dbr dbs dbsq dbss dbrun dbnxt dbret dbjmp dbsig'
SCRIPTNAMES=. t,' dbrr dbrrx dberr dberm dbstk dblxq dblxs dbstack'

dbr=:       13!:0    NB. reset, set suspension mode (0=disable, 1=enable)
dbs=:       13!:1    NB. display stack
dbsq=:      13!:2    NB. stop query
dbss=:      13!:3    NB. stop set
dbrun=:     13!:4    NB. run again
dbnxt=:     13!:5    NB. run next
dbret=:     13!:6    NB. exit and return argument
dbjmp=:     13!:7    NB. jump to line number
dbsig=:     13!:8    NB. signal error
dbrr=:      13!:9    NB. re-run with specified arguments
dbrrx=:     13!:10   NB. re-run with specified executed arguments
dberr=:     13!:11   NB. last error number
dberm=:     13!:12   NB. last error message
dbstk=:     13!:13   NB. call stack
dblxq=:     13!:14   NB. latent expression query 
dblxs=:     13!:15   NB. latent expression set

NB. dbstack
NB. displays call stack with header
NB. if  x.=0  ignores definition and source script (default)
NB.        1  displays full stack
NB. y. is the number of lines to display, all if empty
NB. limits display of each item to length 30.
dbstack=: 3 : 0
0 1 dbstack y.
:
'xn'=. 2{.x.
hdr=. 'name';'en';'ln';'nc';'def';'script';'args';'locals'
stk=. (>:n)}.13!:13''
if. #y. do. stk=. (,y.){.stk end.
stk=. hdr,stk
stk=. stk #~"1 (0~:x) >. 1 1 1 1 0 0 1 1 
tc=. 31&<.@$ {.!.'.' ({.~ 30&<.@$)
tc@": &.>stk
)
