% % Example of an exception handler % % This reads in two numbers, divides them, and prints the result. % An exception handler will catch division by zero. % Exit when both inputs are 0. % function Divide(top,bottom : real) : real handler(exceptionNumber) if exceptionNumber = excpDivOrModByZero then put "Divide by zero! Result set to " .. else put "Error" quit end if result 0 end handler result top/bottom end Divide var Dividend,Divisor,Result : real loop put "Dividend? " .. get Dividend put "Divisor? " .. get Divisor exit when Divisor = 0 and Dividend = 0 put Dividend,"/",Divisor," = ",Divide(Dividend,Divisor) end loop