ON ERROR GOTO
This page was last modified 19:27, 12 August 2021 by Mars2000you. Based on work by Gdx.

Contents

Effect

Jumps to a specified line of an error-handler routine, whenever an eror occurs.

It's useful in the following situations:
- for defined errors in MSX-BASIC and Disk Basic, you want to avoid the display of the error messages
- for non-defined errors, you decide to define them and to handle them directly in your program

Important! Always add ON ERROR GOTO 0 at the end of your error-handler routine. For all errors that are not handled by your program, MSX-BASIC will use the normal error-handler procedure.

Syntax

ON ERROR GOTO <LineNumber>

Parameter

<LineNumber> is a program line number of your error-handler routine.

Example

10 ON ERROR GOTO 400
20 INPUT "X= ";A
30 IF A>100 THEN ERROR 210
40  IF A<10 THEN ERROR 211
50 END
400 IF ERR=210 THEN PRINT "MAXIMUM 100!"
410 IF ERR=211 THEN PRINT "MINIMUM 10!"
420 RESUME 20
430 ON ERROR GOTO 0

Related to

ERL, ERR, ERROR, RESUME

Compatibility

MSX-BASIC 1.0 or higher