>>>>Hi,
>>>>
>>>>My app keeps log of all errors that a user would come across. I periodically checks this error log in order to "clean" up issues that users never report. Often times it is hard to figure what actually caused the error.
>>>>
>>>>Therefore, I decided to add 2 more pieces of information to the error log:
>>>>1. Last key user pressed (lastkey())
>>>>2. Where did he/she clicked with the mouse. And this one I don't know how to do. How can I "catch" (and would this really be helpful) where the user clicked right before the error occurred?
>>>>
>>>>TIA.
>>>Dmitry,
>>>
>>>I fully agree with Cetin, f.y.i. I have in my Error.log
>>>
>>>
>>>ASTK Local A errorlogging
>>> ( 1, 1) N 1 ( 1,00000000)
>>> ( 1, 2) C "d:\foxproprojects\zorgenzekerheid\classes\googlemailcomposer.vct"
>>> ( 1, 3) C "frmgooglemail1.gglmailbox1.gglgrid1.column1.gglcntgrid1.lblname.click"
>>> ( 1, 4) C "d:\foxproprojects\zorgenzekerheid\classes\googlemailcomposer.vct"
>>> ( 1, 5) N 1 ( 1,00000000)
>>> ( 1, 6) C "this.Parent.doit()"
>>> ( 2, 1) N 2 ( 2,00000000)
>>> ( 2, 2) C "d:\foxproprojects\zorgenzekerheid\classes\googlemailcomposer.vct"
>>> ( 2, 3) C "frmgooglemail1.gglmailbox1.gglgrid1.column1.gglcntgrid1.doit"
>>> ( 2, 4) C "d:\foxproprojects\zorgenzekerheid\classes\googlemailcomposer.vct"
>>> ( 2, 5) N 77 ( 77,00000000)
>>> ( 2, 6) C " .Left = m.lnLeft"
>>> ( 3, 1) N 3 ( 3,00000000)
>>> ( 3, 2) C "d:\foxproprojects\zorgenzekerheid\progs\errorlogging.fxp"
>>> ( 3, 3) C "ON... "
>>> ( 3, 4) C "d:\foxproprojects\zorgenzekerheid\progs\errorlogging.prg"
>>> ( 3, 5) N 91 ( 91,00000000)
>>> ( 3, 6) C "= Astackinfo(m.aStk)"
>>>
>>>
>>>
>>>which is produced by this code:
>>>
>>>
>>>For i = Alen(m.aStk, 1) - 1 To 1 Step - 1
>>>* I named each element to make it easier to understand (jjh)
>>> lcCurPrg = m.aStk(m.i, 2)
>>> lcModule = m.aStk(m.i, 3)
>>> lcSource = m.aStk(m.i, 4)
>>> lcModLine = Transform(m.aStk(m.i, 5))
>>> lcSrcCode = m.aStk(m.i, 6)
>>>
>>>
>>>Regards,
>>>
>>>Koen
>>
>>Maybe I missing something. But I don't see in your code above showing the Lastkey() or what user pressed that "caused" the error. Is it there but I don't see it?
>
>When you have the whole call stack, it tells you exactly what lines of code produced the error. You don't need the keystroke. I use a routine I call GetStack() that looks like this:
>
>
>* Return the call stack as a string
>
>LOCAL lnStackSize, laCallStack[1], lcStackInfo, lnStackLevel
>STORE 0 TO lnStackSize, laCallStack[1], lnStackLevel
>STORE SPACE(0) TO lcStackInfo
>* Use ASTACKINFO()
>lnStackSize = ASTACKINFO(laCallStack)
>FOR lnStackLevel = 1 TO m.lnStackSize
> lcStackInfo = m.lcStackInfo + ;
> " Level: " + TRANSFORM(laCallStack[m.lnStackLevel, 1]) + CHR(13) + CHR(10) + ;
> " File: " + laCallStack[m.lnStackLevel, 2] + CHR(13) + CHR(10) + ;
> " Module/Object: " + laCallStack[m.lnStackLevel, 3] + CHR(13) + CHR(10)
> lcStackInfo = m.lcStackInfo + ;
> " Line: " + TRANSFORM(laCallStack[m.lnStackLevel, 5]) + ;
> ": " + laCallStack[m.lnStackLevel, 6] + CHR(13) + CHR(10)
>ENDFOR lnStackLevel = 1 TO m.lnStackSize
>
>
>RETURN m.lcStackInfo
>
>
>By having it as a separate function, I can use it other debugging code. For example, when I don't understand why/where a particular property is changing, I'll add an assign method to the property and put code in it like:
>
>
>DEBUGOUT PROGRAM()
>DEBUGOUT " New value =", m.tuNewValue
>DEBUGOUT ""
>DEBUGOUT "--- Call stack ---"
>DEBUGOUT getstack()
>DEBUGOUT "--- End call stack"
>DEBUGOUT ""
>
>
>Then, I can test and see every time the property gets changed, exactly what was going on.
>
>Tamar
First, thank you very much for the code. But the line number only gets into the Stackinfo only if I include the code into the .exe. And I typically do not. Are you saying that you - when building your app - check Debug info in the project? I tried it once and it almost doubled the size of the .exe.
Also, regarding your approach of DEBUGOUT. I thought that DEBUGOUT only works when running the app from IDE, not when executing it as .EXE on customer system. Am I wrong about it?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham