Please enable JavaScript to view this site.

A-Shell Reference

Written July 2020

ON ERROR GOTO <label>

ON ERROR GOTO

ON ERROR GOTO establishes the specified label as an error trap, such that the runtime system redirects to that location when an ASB error is detected. The error trap routine should then handle any appropriate error recovery activities such as logging, reporting and/or determining what to do next. In order to clear the error and resume operation of the program, see the RESUME statement.

ON ERROR GOTO without any label effectively disables the error trap. When there is no error defined, the default response to an error is to abort the program and output a message to the screen giving the error number, last file, and last location.

Example

    ON ERROR GOTO TRAP

    ...

START:

    ...

TRAP:

    ? "Error ";ERR(0)

    IF ERR(0) = 1 THEN    ! if ^C ...

        RESUME START      ! resume at START label

    ELSE

       CHAIN "MAIN"       ! else chain to main menu

    ENDIF

 

See Also

ERR function
Error Trapping in SBX routines