Onerror1.txt

Warning: if you clip this code into your program, look out for possible html code slipping in.

REM ON ERROR EXAMPLE - DIVIDE BY ZERO

REM Only one error handler is active; the last one installed by an ON ERROR statement


VITAL SUBROUTINE error_handler( error_code AS INTEGER )

SELECT error_code
	CASE 20
		PRINT "Integer Division by ZERO..."

	CASE 21
		PRINT "Exponentiation imaginary..."

	CASE 22
		PRINT "Exponentiation overflow..."

	CASE ELSE
		PRINT "ERROR code UNDEFINED"		
ENDSELECT
END


REM main loop...divide by ZERO error example
REM a divide by zero will take place when index reaches zero

GLOBAL index AS INTEGER, number AS INTEGER

ON ERROR error_handler
index=4:number=1000

DO WHILE 1
	index=index-1
	number=number/index
LOOP