formadmirer
asked on
VFP Revert ON ERROR
Hi all - quick question...
How do I capture the current ON ERROR so that I may temporarily assign a new ON ERROR event and then revert to the original?
Thanks!
How do I capture the current ON ERROR so that I may temporarily assign a new ON ERROR event and then revert to the original?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nothing to add. Go for TRY..CATCH. Your temporary error event code goes into the CATCH block.
Bye, Olaf.
Bye, Olaf.
ASKER
Just did it with TRY...CATCH and love it. Never used it before. Much nicer, cleaner and easier to use - thank you!
LOCAL lcOnError
lcOnError = ON("ERROR")
*-- Suppressing the ON ERROR behavior
ON ERROR *
STORE tertewr TO ryeuirweiru && This command should not generate error
*-- Restoring the previous setting
IF EMPTY(m.lcOnError)
ON ERROR
ELSE
ON ERROR &lcOnError
ENDIF
Of course, if some outer TRY - CATCH is active or if you are in an object then the error may be captured by another method.