40 ON range

This error will be generated if, in a simple ON...GOTO/GOSUB/PROC statement, the control variable was less than 1 or greater than the number of entries in the ON list. These exceptions can be trapped in ON GOTO/GOSUB/PROC statements by using the ELSE option. The first example below will generate an 'ON range' error, whilst the second is correct.

10 num=4
20 ON num GOTO 100,200,300
10 num=4
20 ON num GOTO 100,200,300 ELSE 1000