Groups > dBase > dBase support > Re: Finding the name of the calling program.




Re: Finding the name of the calling program.

Re: Finding the name of the calling program.
Thu, 27 Dec 2007 07:12:55 -080
Matt wrote:
> Ken,
> 
> In our error trapping program we do capture those pieces of 
> information (program(), lineno(), error(), message()). I got a screen
>  capture of what I was looking at while the program encountered an 
> error. If this is the compiler, I don't know that we could use the 
> information at runtime, but I need some verification. If it isn't, I 
> might be able to use it somehow.

I believe the info you're seeing is output from the compiler, although
it may be the runtime engine. It's hard to say.

Try creating a program that is based on what I posted before, with the 
name "globalErrorTrap.prg" -- then put the code I posted in there:

function globalErrorTrap(cProg, nLineno, nError, cMsg)

   local c
   #define CHAR_CR chr(13)
   c = cMsg  + CHAR_CR + CHAR_CR + ;
       "In: "    + cProg + CHAR_CR + ;
       "Line: "  + nLineno + CHAR_CR + CHAR_CR + ;
       "If this error persists, contact program vendor."
*  msgbox(c, "Unexpected Application Error [" + nError +"]",
16)
? c
wait

   quit

---

Then to call it:

on error do globalErrorTrap with program(), lineno(), error(), message()

> I guess the real need from all of this is that we are working on 
> getting our lock tracking program running with information we want. 
> The program() returns the current program which gathers our lock 
> information. We want the calling program's name to place it in our 
> lock table. So we want to get the program that used the locking 
> program vs the locking program's name in the table. This way we can 
> check and see what programs lock the most, etc.

Instead of outputting it to the screen, your global error trap could add 
the data you need to the table ...

use errortable
append blank
replace progname with cProg
use

(For example)

Ken

-- 
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
Post Reply
about | contact