Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF (EN)

126 10 ON ERROR GOTO 2000 20 PRINT "HELLO" 30 PRINT 3/0 40 PRINT "BYE" 50 END 2000 PRINT ERR 2010 PRINT ERL >RUN HELLO 18 30 As you will see from the above the computer detected error number 18 in line number 30. Instead of just printing an error number the computer can be made to deal with the problem. Look at the next program which will generate an error when X gets to zero. 100 X=-5 110 PRINT X, 3/X 120 X=X+1 130 IF X 140 END >RUN -5 -0.6 -4 0.75 -3 -1 -2 -1.5 -1 -3 0 Division by zero at line 110 If we put in error handling routine we can let the computer deal with the problem itself. 10 ON ERROR GOTO 1000 100 X=-5 110 PRINT X, 3/X 120 X=X+1 130 IF X 140 END 1000 IF ERR=18 THEN PRINT:

GOTO 120 1010 REPORT >RUN -5 -0.6 -4 -0.75 -3 -1