`prev Menu next`

Introduction to BASIC Exception Handling

WHEN ～ END WHEN
Errors that occur on execution are called exceptions.
Division by zero or overflow is an example of an exception.
Exception handling enables continuation of a program when an exception has occurred.

Example. The graph of the function y=1/x

    10 SET WINDOW -4,4,-4,4
    20 FOR x=-4 TO 4 STEP 0.01
    30    WHEN EXCEPTION IN
    40         PLOT LINES: x,1/x;
    50    USE
    60         PLOT LINES
    70    END WHEN
    80 NEXT x
    90 END

The statements written between the USE line and the END-USE line are not executed ordinarily.
If an exception has occurred in a statement written between the WHEN-EXCETION-IN line and the USE line, the control shall be switched to the next line of the USE line.
A PLOT LINES statement with no arguments disconnects the continuation of segments.

Refer to Execption Handling