Friday 14 April 2023

vfp log error | vfp9 save runtime error in dbf | log error saving into t...




You can log the error in dbf table with the help of following code.


ERRLOG.PRG code

ON ERROR DO errHandler WITH ;
   ERROR(), MESSAGE(), MESSAGE(1), PROGRAM(), LINENO()
   clear
USE nodatabase  

PROCEDURE errHandler
   PARAMETER merror, mess, mess1, mprog, mlineno
   CLEAR
   ? 'Error number: ' + LTRIM(STR(merror))
   ? 'Error message: ' + mess
   ? 'Line of code with error: ' + mess1
   ? 'Line number of error: ' + LTRIM(STR(mlineno))
   ? 'Program with error: ' + mprog
   USE ErrorLog
   APPEND BLANK
   replace errorno WITH LTRIM(STR(merror))
   replace errmsg WITH mess
   replace errline WITH mess1
   replace lineno WITH LTRIM(STR(mlineno))
   replace progname WITH mprog
   replace errdatetim WITH DATETIME()
ENDPROC




Structure for table:   ERRORLOG.DBF
Number of data records:       7       
Date of last update:          04/09/23
Code Page:                    1252    
  Field   Field Name              Type                            Width       Dec     Index   Collate       Nulls        Next        Step
      1   ERRORNO                 Character                          10                                        No
      2   ERRMSG                  Character                         254                                        No
      3   ERRLINE                 Character                         254                                        No
      4   LINENO                  Character                          10                                        No
      5   PROGNAME                Character                          50                                        No
      6   ERRDATETIM              DateTime                            8                                        No
** Total **                                                         587



vfp log error, vfp9 save runtime error in dbf, log error saving into table, error save in dbf vfp

Sunday 2 April 2023

01 vfp error handle | Error handling in VFP9 | display error runtime in ...



Error Handling in Visual Foxpro VFP9

First.prg Code:

ON ERROR Do MsgDisp with ERROR(),MESSAGE()
CLEAR
USE FirstRec



MsgDisp.prg Code:

PARAMETERS ErrNo, Msg
MESSAGEBOX("Error No."+STR(ErrNo)+CHR(13)+CHR(13)+Msg,0+16,"Manoj Kalla Training")