分区助手专业版下载:錯誤記錄程序

来源:百度文库 编辑:偶看新闻 时间:2024/05/06 04:52:49

 錯誤記錄程序

****************************************
*功能:把程序運行過程中所出現的問題寫入ERROR.TXT文件中,以便事後查看修正
*調用:On Error Do ErrorHand With Error(),Program( ), Program(1),Program(2),Sys(16,0),Lineno( )
****************************************
Function ErrorHand
Parameters nError, cMethod, cMethod1,cMethod2,cSys16,nLine
Local lcSys16,lnFile
lcSys16=Sys(16,0)
lcSys16=Justpath(Subst(lcSys16,At(":", lcSys16) - 1))+'\'+'Error.txt'
If File(lcSys16)
lnFile=Fopen(lcSys16,12)&&以讀寫方式打開
Else
lnFile=Fcreate(lcSys16,0)&&以讀寫方式建立
Endi
If lnFile<0
Chr(7)
Messagebox('不能打開或新建 Error.txt 文件,請與程式設計人員聯繫',16,'錯誤!')
Else&&把錯誤信息寫入ERROR.TXT文件中
=Fseek(lnFile,0,2)
=Fputs(lnFile,'***************************************')
=Fputs(lnFile,'DateTime: '+Ttoc(Datetime()))
=Fputs(lnFile,'Error Num: '+Allt(Str(nError)))
=Fputs(lnFile,'Error Message: '+Message())
=Fputs(lnFile,'Error Line: '+Allt(Str(nLine)))
=Fputs(lnFile,'Error Code: '+Message(1))

=Fputs(lnFile,'Error Prog(0): '+cMethod)
=Fputs(lnFile,'Error Prog(1): '+cMethod1)
=Fputs(lnFile,'Error Prog(2): '+cMethod2)
=Fputs(lnFile,'Error Sys(16): '+cSys16)

=Fclose(lnFile)
Endif
Return