Hi, I'm creating reusable blocks of code, and in one block I'd like to turn the error handler off (because I'm running 'address system' calls and handle the return codes myself), but at the end would like to restore the error handler. There are two issues that I would appreciate suggestions on:
Is it possible to determine if the caller used "call on error" or "signal on error" so I could correctly use "call on error" or "signal on error" at the end of my code block? (Testing shows that "signal off error" seems to work whether the calling routine used "call" or "signal".)
If there is a handler name (e.g., "signal on error name err"), is it possible to save and restore the name of the condition handler? (I know we could just not use handler names, but there are a couple programs that have two different error condition handlers, so one would need a unique name.)
Thanks!
Last edit: cniggeler 2019-11-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After reading condition handling in more detail and with some experimentation, I believe I've answered my own question: Create a string that is the error handler, and then INTERPRET that. Here is a code sample:
errhand="call on error name err"interpreterrhandi=1sayfoo(i)addresssystem'heiaes2>NUL'saybyereturnfoo:signalofferroraddresssystem'heiaes2>NUL'interpreterrhandreturn100*ierr:say"error @"SIGLreturn
and the results:
100
error @5
BYE
Better suggestions would be appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I'm creating reusable blocks of code, and in one block I'd like to turn the error handler off (because I'm running 'address system' calls and handle the return codes myself), but at the end would like to restore the error handler. There are two issues that I would appreciate suggestions on:
Is it possible to determine if the caller used "call on error" or "signal on error" so I could correctly use "call on error" or "signal on error" at the end of my code block? (Testing shows that "signal off error" seems to work whether the calling routine used "call" or "signal".)
If there is a handler name (e.g., "signal on error name err"), is it possible to save and restore the name of the condition handler? (I know we could just not use handler names, but there are a couple programs that have two different error condition handlers, so one would need a unique name.)
Thanks!
Last edit: cniggeler 2019-11-07
After reading condition handling in more detail and with some experimentation, I believe I've answered my own question: Create a string that is the error handler, and then INTERPRET that. Here is a code sample:
and the results:
100
error @5
BYE
Better suggestions would be appreciated.