exception-endexception
Exceptions let you find errors in the program. Error handling when a exception is occurred.
Syntax:
- exception exceptionName
- Programmcode
- [Raise]
- endexception
Exception Name | Description | Raise |
---|---|---|
DivisionByZero1) | Division by Zero occurred in a calculation | yes |
OutOfBoundsMemory | MemoryBlock Object Boundry violation | yes |
NilObjectexception | Referred object does not exist | yes |
OutOfSpaceMemory | Memory full, Object can not be allocated | no |
StackOverflow | Stack has overflowed. See also.. | no |
The exception handler in your code activates the appropriate debug function. Execution speed is reduced in some cases and additional memory in Flash is required. If possible (see Table), Raise will continue with code execution. In other cases the program will enter an endless (HALT) loop.
See also: Dump
Example
' Initialization [..] ' Main Program dim a as byte dim m,m1 as MemoryBlock m.New(100) 'Allocate a Memory Block with 100 Byte a=m.ByteValue(100) 'Raises an "out of range" exception '(Access only 0-99, Offsets are zero based) m1.ByteValue(0)=1 'Object does not exist m1.New(3000) 'More memory allocated as available (Program will stop) do Loop ' Define an Exception Handler (activates the monitoring function) exception OutOfSpaceMemory 'Show error message Print "*** exception OutOfSpaceMemory ***" endexception exception OutOfBoundsMemory 'Show error message Print "*** exception OutOfBoundsMemory ***" Raise 'Continue execution endexception exception NilObjectexception 'Show error message Print "*** exception NilObjectexception ***" Raise ' Programm fortführen endexception exception StackOverflow 'Show error message Print "*** exception StackOverflow ***" endexception
1)
As of Version 2015.r1