In PowerBASIC, error codes - returned by the ERR or ERRCLEAR functions - and error traps are local to each Sub or Function. An error trap will only trap errors that occur within the Sub or Function 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:
SUB Proc1
ON ERROR GOTO ErrorTrap
' some code goes in here
CALL Proc2
' some more code goes in here
Proc1Resume:
EXIT SUB
ErrorTrap:
' Error-handling code goes in here
RESUME Proc1Resume
END SUB
See Also