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

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

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

Use Global Variable to tell Errorhandler to Ignore Specific Errors

 Keywords: IntControl 73 ErrorMode Global Variable Error Handler Ignore Skip Specific Pointer WBERRORHANDLER

Question:

I would like to have the WBERRORHANDLER handle errors from some functions but skip or ignore some other errors. How can this be accomplished?

Answer:

You could set a global flag telling IntControl to temporarily skip Error handling.

For Example:

#DefineFunction OnNextError(wberrorarray)

   ;Check global variable to see if you should ignore error
   ptr_gSkipErrorHandling=PtrGlobal(gSkipErrorHandling)
   If *ptr_gSkipErrorHandling == 1
       Pause('Debug','Ignoring this error ': wberrorarray[0])
       Return(1) ; Re-arm error handler
   EndIf

   lasterr = wberrorarray[0]
   handlerline = wberrorarray[1]
   textstring = wberrorarray[5]
   linenumber = wberrorarray[8]
   errstr = StrCat("Number: ",lasterr,@LF,"String: ",textstring,@LF,"Line (",linenumber,"):'",handlerline,"'")
   Message("Error Information",errstr)
   Return(1) ; Re-arm error handler
#EndFunction

#DefineFunction BadFunct()
   IntControl(73,3,0,"OnNextError",0); Re-arm error handler
   Message(cccc,dddd)
   Return(1)
#EndFunction

;Define A global variable to set if you want to skip error handling
PtrGlobalDefine(gSkipErrorHandling)

; Tells the error handler to handle errors
gSkipErrorHandling = 0

; Arm error handler in main routine
IntControl(73,3,0,"OnNextError",0)

BadFunct() ;This error will be handled by OnNextError

; Tells the error handler to skip error handling
gSkipErrorHandling = 1

BadFunct()  ;This error will be ignored by OnNextError

Exit

Article ID:   W17950
Filename:   Use Global Varaible to tell Errorhandler to Ignore Specific Errors.txt
File Created: 2011:07:22:10:48:44
Last Updated: 2011:07:22:10:48:44