Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -0,0 +1,10 @@
|
|||
100 REM TRY
|
||||
110 ONERR GOTO 200
|
||||
120 D = - 44 / 0
|
||||
190 END
|
||||
200 REM CATCH
|
||||
210 E = PEEK (222) < > 133
|
||||
220 POKE 216,0: REM ONERR OFF
|
||||
230 IF E THEN RESUME
|
||||
240 CALL - 3288: REM RECOVER
|
||||
250 PRINT "DIVISION BY ZERO"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
PROCdivide(-44, 0)
|
||||
PROCdivide(-44, 5)
|
||||
PROCdivide(0, 5)
|
||||
PROCdivide(5, 0)
|
||||
END
|
||||
|
||||
DEF PROCdivide(numerator, denominator)
|
||||
ON ERROR LOCAL IF FALSE THEN
|
||||
REM 'Try' clause:
|
||||
PRINT numerator / denominator
|
||||
ELSE
|
||||
REM 'Catch' clause:
|
||||
CASE ERR OF
|
||||
WHEN 18: PRINT "Division by zero"
|
||||
WHEN 20: PRINT "Number too big"
|
||||
OTHERWISE RESTORE LOCAL : ERROR ERR, REPORT$
|
||||
ENDCASE
|
||||
ENDIF
|
||||
ENDPROC
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
result = DetectDividebyZero(1, 0)
|
||||
|
||||
|
||||
Function DetectDividebyZero(a, b)
|
||||
On Error GoTo [Error]
|
||||
DetectDividebyZero= (a/ b)
|
||||
Exit Function
|
||||
[Error]
|
||||
If Err = 11 Then '11 is the error number raised when divide by zero occurs
|
||||
Notice "Divide by Zero Detected!"
|
||||
End If
|
||||
End Function
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
10 ON ERROR GOTO 60
|
||||
20 PRINT 2/3
|
||||
30 PRINT 3/5
|
||||
40 PRINT 4/0
|
||||
50 END
|
||||
60 IF ERR=11 THEN PRINT "Division by zero in line"ERL:RESUME 50
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
;Set up a Procedure to handle any Error
|
||||
Procedure MyErrorHandler()
|
||||
Define txt$="The following error happened."+#CRLF$+ ErrorMessage()+"at line "+Str(ErrorLine())
|
||||
MessageRequester("OnError test", txt$)
|
||||
EndProcedure
|
||||
|
||||
; Tell where to go if an Error happens
|
||||
OnErrorCall(@MyErrorHandler())
|
||||
|
||||
;Now, do something very stupid so that we may see an Error...
|
||||
Repeat
|
||||
A=Random(100)/Random(100)
|
||||
ForEver
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Define.d a, b
|
||||
Debug a/b
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
on error goto [error]
|
||||
a = 1 / 0
|
||||
wait
|
||||
|
||||
[error] ' error 11 is division by zero err number
|
||||
If err = 11 Then print "Division by Zero"
|
||||
wait
|
||||
|
|
@ -6,6 +6,6 @@ divcheck x y:
|
|||
not
|
||||
|
||||
if divcheck 1 0:
|
||||
print "Okay"
|
||||
!print "Okay"
|
||||
else:
|
||||
print "Division by zero"
|
||||
!print "Division by zero"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
@(do (defun div-check (x y)
|
||||
(catch (/ x y)
|
||||
(numeric_error (msg)
|
||||
'div-check-failed))))
|
||||
@(bind good @(div-check 32 8))
|
||||
@(bind bad @(div-check 42 0))
|
||||
Loading…
Add table
Add a link
Reference in a new issue