[Harbour] How to retrieve the CallStack

Alex Strickland sscc at mweb.co.za
Mon Mar 1 02:37:35 EST 2010


francesco perillo wrote:

> I now ask if is it possible to get a prg-level CallStack array in
> order to use it in the errorsys handler.

I use:

function Stack2Str(n)

     local cStackStr := ""
     local cProcFile

     DEFAULT n TO 2

     while !empty(procname(n))
         cStackStr += "Called from " + procname(n) + "(" + 
alltrim(str(procline(n))) + ")" + iif(empty(cProcFile := procfile(n)), "", " in 
" + cProcFile) + chr(13) + chr(10)
         n++
     end

return cStackStr

HTH
Alex



More information about the Harbour mailing list