WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Error Codes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Initialize a WB Error

Keywords: 	   Initialize a WB Error	IntControl (79,	Intcontrol(79, user defined error

Question:

Is it possible to create some error that the lasterror function will read and compute? ex;
value = inireadpvt("section", "value", "novalue", inifile)
if value == "novalue" then set_error

:WBERRORHANDLER 
ret = LastError()
dowritefile(logfile, pcname, ret)
Exit
i hope you can understand my need.

Answer:

Take a look at IntControl (79, p1, p2, p3, 0)
IntControl (73, 2, 0, 0, 0)
IntControl (79,-1, 7001, "7001: Minor ERROR!", 0)
IntControl (79,-2, 7002, "7002: Moderate ERROR!!", 0)
IntControl (79,-3, 7003, "7003: Severe ERROR!!!", 0)
exit

:WBERRORHANDLER
wbError = LastError()
wbTextcode=wbError
if wberror==1668 || wberror==2669 || wberror==3670
   msg=IntControl(34,-1,0,0,0)
   wberror=ItemExtract(1,msg,":")
   wbTextcode = -1
endif
wbErrorMsg = ""
wbErrorMsg = StrCat(wbErrorMsg,"LastError value:",@LF,wbError,@LF,@LF)
wbErrorMsg = StrCat(wbErrorMsg,"LastError string:",@LF,IntControl(34,wbTextcode,0,0,0),@LF,@LF)
If ItemLocate(wbError,"1668,2669,3670",",")
   ; 1668 ; "Minor user-defined error"
   ; 2669 ; "Moderate user-defined error"
   ; 3670 ; "Severe user-defined error"
   wbErrorMsg = StrCat(wbErrorMsg,"User-defined error:",@LF,IntControl(34,-1,0,0,0),@LF,@LF)
EndIf
; Line in script that caused Error.
wbErrorMsg = StrCat(wbErrorMsg,"wbErrorHandlerLine:",@LF,wbErrorHandlerLine,@LF,@LF)
; Offset into script of error line, in bytes.
wbErrorMsg = StrCat(wbErrorMsg,"wbErrorHandlerOffset:",@LF,wbErrorHandlerOffset,@LF,@LF)
; Variable being assigned on error line, or "" if none.
wbErrorMsg = StrCat(wbErrorMsg,"wbErrorHandlerAssignment:",@LF,wbErrorHandlerAssignment,@LF,@LF)
If (wbErrorhandlerassignment>"") Then %wbErrorhandlerassignment% = "eeek"
Message("wbErrorHandler",wbErrorMsg)
IntControl (73, 2, 0, 0, 0)
Return
Exit



Article ID:   W15496
File Created: 2003:05:13:11:28:14
Last Updated: 2003:05:13:11:28:14