In PowerBASIC, error codes - returned by the ERR or ERRCLEAR functions - and error traps are local to each Sub, Function, Method, or Property. An error trap will only trap errors that occur within the procedure where it is defined.
PowerBASIC uses the following steps to determine what to do when a run-time error occurs:
Does an error trap exist? If so, PowerBASIC uses it.
If no error trap exists, PowerBASIC places an error code in the ERR and ERRCLEAR system variables and continues execution.
Consider the following:
ON ERROR GOTO ErrorTrap
' some code goes in here
' some more code goes in here
' Error-handling code goes in here
Setting an error trap
Writing an error handler
Exiting an error handler
Error Trapping Summary