Statements and Functions Used for Trapping Events and Errors Task Statement or Function Action Trapping errors ON ERROR GOTO line Causes a program to branch to while a program the given line where line is running refers either to a line number or line label. Branching takes place whenever an error occurs during execution. RESUME Returns control to the program after executing an error-handling routine. The program resumes at either the statement causing the error (RESUME [0]), the statement after the one causing the error (RESUME NEXT), or the line iden- tified by line (RESUME line). Getting ERR Returns the code for an error error-status that occurs at run time data ERL Returns the number of the line on which an error occurred (useful only if program has line numbers) ERDEV Returns a device-specific error code for the last device (such as a printer) for which DOS detected an error ERDEV$ Returns the name of the last device for which DOS detected an error Defining your ERROR Simulates the occurrence of own error codes a BASIC error; can also be used to define an error not trapped by BASIC Trapping events ON event GOSUB line Causes a branch to the while a program subroutine starting with line, is running where line refers either to a line number or line label, whenever the given event occurs during execution. event ON Enables trapping of the given event event OFF Disables trapping of the given event event STOP Suspends trapping of the given event RETURN Returns control to the program after executing an event-handling subroutine. The program resumes at the statement immediately following the place in the program where the event occurred (RETURN), or the line that is identified by line (RETURN line).