Original Author Paul Laughton, 2011
Page 89
De Re BASIC!
If you have not written that Interrupt Label into your program, the event is ignored and your
program goes on running as if nothing happened.
If you have included the right Interrupt Label for the event, BASIC! jumps to that label and continues
execution at the line after the label. This is called trapping the event.
BASIC! does not necessarily respond to the event as soon as it occurs. The statement that is executing
when the event occurs is allowed to complete, then BASIC! jumps to the Interrupt Label.
When you use an Interrupt Label to trap an event, BASIC! executes instructions until it finds a Resume
command that matches the Interrupt Label. During that time, it records other events but it does not
respond to them. The block of code between the Interrupt Label and the matching Resume may be
called an Interrupt Service Routine (ISR) or, if you prefer, an Event Handler.
When BASIC! executes the event's Resume command, it resumes normal execution.
BASIC! jumps back to where it was running when the interrupt occurred.
BASIC! again responds to other events, including any that occurred while it was handling an event.
An Interrupt Label looks and behaves just like any other label in BASIC!. However, you must not execute
any of the Resume commands except to finish an event's handler.
All Interrupt Labels
BASIC! supports trapping of the following events. These interrupt labels and their Resume commands
are described in various parts of this manual.
OnBackground:
Background.resume
OnBackKey:
Back.resume
OnBtReadReady: Bt.onReadReady.resume
OnConsoleTouch: ConsoleTouch.resume
OnError:
None (not a true event, see OnError:, below)
OnGrTouch:
Gr.onGrTouch.resume
OnKbChange:
Kb.resume
OnKeyPress:
Key.resume
OnLowMemory:
LowMemory.resume
OnMenuKey:
MenuKey.resume
OnTimer:
Timer.resume
OnError:
Special interrupt label that traps a run-time error as if it were an event, except that:
OnError: has no matching Resume command. You can use GoTo to jump anywhere in your program.
OnError: is not locked out by other interrupts.
OnError: does not lock out other interrupts.
If a BASIC! program does not have an OnError: label and an error occurs while the program is running,
an error message is printed to the Output Console and the program stops running.