21.3. RESUME

[<<<] [>>>]

If you know that the program error does not need error code you can use one of the ON ERROR RESUME statements. These have almost the same effect as the statement ON ERROR GOTO except that the program execution continues in non-error mode when an error happens. This means that the program jumps to the location specified by the statement ON ERROR RESUME, but the error code is zero meaning no error and there is no remembered error location where a statement RESUME could return.

There are two different forms of the statement ON ERROR RESUME. One is similar to the statement ON ERROR GOTO specifying a label where to resume execution after the error. This has the form

ON ERROR RESUME label

The other type has the form

ON ERROR RESUME NEXT

This command tells the interpreter to neglect the erroneous line and continue the operation executing the next line. Although this is a pleasant and easy way handling error, great care has to be taken. If you use the statement ON ERROR RESUME NEXT in a code an error may silently be passed. On the other hand if there are more than one errors in the code the second one will terminate the program execution, because the first error switches off the effect of the statement ON ERROR RESUME NEXT.

The code executing the error correction code can access the error code. The code of the last error happened is returned by the function ERROR(). This function has no argument and returns an integer value, which is the error code. In normal operation, outside of error correction code the value of this function is zero.


[<<<] [>>>]