Hypertext Resume&references|Business and development   Philosophy|Foxpro Design Strategies|Code Sample| Tool Suites

 

Scott Keyes (830) 964-5803    scott_keyes@yahoo.com   http://www.oocities.org/scott_keyes/index.html

The sample below is from an early copy of my standard errorhandler (much ehanced since then) ..there are a couple of odd calls done (for instance to get the screenshot saved) but it pretty much captures everything that can be known about the system...including Novelle connection info, and user comments about the the error, and a screenshot (*.bmp in a general field) and all the user information into a table, which made it the first part of a very very good ticket/tracking system (why should you ASK the user thigns the computer cold tell you?) and certainly made the beta testing of new applications a lot easier...

If youre interested in a good error handler/ticket system for your foxpro applications , just let me know and I'll dig it out for you...

 

Scott Keyes (830) 964-5803    scott_keyes@yahoo.com   http://www.oocities.org/scott_keyes/index.html

 

 

* written by scott keyes  copyright Scott Keyes 1996-1999
* Tested and compatible for visual Foxpro 6, Foxpro for windows 2.6 and Foxpro DOS 2.6
* which means it should run in fox 2.5 (dos and windows) and VFP3 and VFP5 as well.
* it *hasnt* been tested or even contemplated for Foxpro 2.0 but might just work
* slim chance under Fox 1.02 and dont even think about a foxbase or foxbase+ compilation...

PARAMETER thisuser,thismsg,thisline,thisrec,thisdbf,thisdate,thistime,thisprog,thisproc,thiskey

m.prg_dir=SUBSTR(SYS(16),AT("\",SYS(16))-2,RAT("\",SYS(16))-AT("\",SYS(16))+2)
 

* this section will provide user and connection informatin for Novell 4.12 clients
*(probably most other novell versions as well...AND doesnt creat a problem ifyou ARENT using a novell client.)
CREATE TABLE c:\killthis.DBF (onefield c(75))
RUN whoami >>> c:\killthis.txt
APPEND FROM c:\killthis.txt TYPE SDF

LOCATE FOR LEFT(onefield,8)="User ID:"
m.thisuser=ALLTRIM(SUBSTR(onefield,9,66))

LOCATE FOR LEFT(onefield,7)="Server:"
m.server=ALLTRIM(SUBSTR(onefield,8,67))

LOCATE FOR LEFT(onefield,11)="Connection:"
m.thisconnec=ALLTRIM(SUBSTR(onefield,12,63))

LOCATE FOR LEFT(onefield,13)="Current tree:"
m.thistree=ALLTRIM(SUBSTR(onefield,13,62))
 

* this section looks for the errorlog.dbf and creates one if it is not found
IF FILE(m.prg_dir+"\errorlog.dbf")
 IF NOT USED('errorlog')
  USE (m.prg_dir+"\errorlog.dbf")
 ENDIF
ELSE
 CREATE TABLE (m.prg_dir+"\errorlog.dbf") ;
  (trackno N(10),;
  thismsg c(100),;
  thisline N(7),;
  thisproc c(100),;
  thisdbf c(50),;
  thisrec N(8),;
  thiskey c(150),;
  thisuser c(35),;
  thisdate d ,;
  thistime c(35),;
  SERVER  c(75),;
  thisconnec c(75),;
  thistree c(70),;
  causedby m,;
  fixedby m,;
  variables m,;
  varlist m,;
  windowenv m,;
  screenenv m,;
  screencap G,;
  repaired L,;
  repby c(35),;
  repdate D,;
  confirmed L,;
  cnfrmdby c(35),;
  cnfrmddate d,;
  enhancemnt T)
ENDIF

*  this section add the record for this particular error occurance to the log and then
* gather to information into the table.
APPEND BLANK
GO BOTTOM
m.trackno=reccount()
GATHER MEMVAR
SCATTER MEMVAR MEMO
* this section allwos the user to save a screen capture of the application at thepoint of failure.
IF "VISUAL"$ALLTRIM(UPPER(VERSION())) OR "WINDOWS"$ALLTRIM(UPPER(VERSION()))
 WAIT "please press the 'PRINT SCREEN' key, then CTRL+V" WINDOW
 MODIFY GENERAL screencap IN SCREEN
ENDIF

* save the window definiton which can be restored
SAVE WINDOWS ALL TO MEMO windowenv

* this line creates a snapshot of the environment (memory variables and their value)
* at this point which can be restored with a 'restore from' statement
SAVE TO MEMO variables

* redundatnly this makes a listing of the variables and their values at the time
list memory to c:\killthis.txt
APPEND MEMO varlist FROM c:\killthis.txt OVERWRITE

*saves the background screen so it can be restored
*SAVE SCREEN TO screenenv
*REPLACE errorlog.screenenv WITH m.screenenv
 

*this section reports the error to the user and instructs them type the description
*of the sequence of events leading up to the error into the window which opens for that purpose

WAIT "ERROR:"+ALLTRIM(thismsg)+CHR(13)+;
 "line#"+ALLTRIM(STR(thisline))+" of "+ALLTRIM(thisproc)+CHR(13)+;
 "alias "+ALLTRIM(thisdbf)+"at rec#"+ALLTRIM(STR(thisrec))+" key:"+ALLTRIM(thiskey)+ CHR(13)+;
 "user: "+ALLTRIM(thisuser)+" on "+DTOC(thisdate)+" at "+ALLTRIM(thistime)+CHR(13)+;
 ALLTRIM(m.server)+":"+ALLTRIM(m.thisconnec)+":"+ALLTRIM(m.thistree)+CHR(13) WINDOW

WAIT "Please type in the sequence of events that preceded the error."+CHR(13)+;
 " (example:' from main menu,i pressed q then typed 128') "+CHR(13)+;
 " then close the 'errorlog.causedby' window. thanks" WINDOW
 

SELECT errorlog
MODIFY MEMO causedby
USE

PUSH KEY CLEAR
CLEAR
RELE WIND
DO start.prg && use your start programs name here

*use this line to set your "on error" statement..errorhandl.prg has to be in the path though...
*ON ERROR DO errhandl.prg WITH GETENV('user'),MESSAGE(),LINENO(),RECNO(),ALIAS(),DATE(),TIME(),PROGRAM(),SYS(16),KEY()

* use this line if errorhandl.prg is in the same directory as all programs that will call it.
*ON ERROR DO ((SUBSTR(SYS(16),AT("\",SYS(16))-2,RAT("\",SYS(16))-AT("\",SYS(16))+2))+"\errhandl.prg") WITH GETENV('user'),MESSAGE(),LINENO(),RECNO(),ALIAS(),DATE(),TIME(),PROGRAM(),SYS(16),KEY()

*RESTORE FROM MEMO variables
*RESTORE WINDOW  ALL FROM MEMO windowenv
*RESTORE SCREEN FROM screenenv