Amos Professional Manual  Contents  Index

Error Handling


RESUME LABEL
structure: jump to a label after an error has been isolated using a procedure
Resume Label label

This defines the label which is to be returned to after an error. It must be called outside of your error handler, immediately after the original ON ERROR PROC or ON ERROR GOTO statement. For an example of RESUME LABEL, please see the last routine in this Chapter.

ERRN
function: return the error code number of the last error
number=Errn
Print Errn

When you use ON ERROR to create error handling routines, you will want to know exactly what sort of error has happened in the main program. Errors discovered while your program is running each have a specific error code number, and the number of the last error to be isolated can be returned by using the ERRN function.

ERROR
instruction: deliberately generate an error and return to Editor
Error number

Supposing you have set up an error handling routine and you want to test your programming skills. The ERROR command offers a simple method of simulating various mistakes without all the inconvenience of waiting for them to happen. To test this system, select the error of your choice using the error code numbers listed in the next Chapter. For example:

X> Error 88

That will quit your program and display a Disc full error message, simulating what would happen when your current disc gets filled with data. You may also combine ERROR with the ERRN function, to print out the current error condition, after a problem in your program:

X> Error Errn

Finally, ERROR can be used with RESUME LABEL inside an error handling routine, to jump straight back to a label set up with the previous command. For example:

E> On Error Proc HELP
   Resume Label WELCOME
   Error 88
   Print "This line is never printed"
   WELCOME : Print "Hello! Hello! I'm back again!"
   End
   Procedure HELP
    Print "There seems to be an error!"
    Resume Label
   Endproc
Back    Next
12.02.03