bas7qck.hlp (Table of Contents; Topic list)
Setting Traps for Events and Errors
  Programming Tasks                            Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
Statements and Functions Used for Setting Traps for Events and Errors
 
                  Statement or
Task              function               Action
═══════════════   ════════════════════   ═══════════════════════════════════
Trapping errors   ON ERROR               Enables an error-handling routine
while a program                          and specifies the location of
is running                               that routine in the program. Also
                                         used to disable an error-handling
                                         routine.
 
                  RESUME                 Returns control to the program
                                         after executing an error-handling
                                         routine.
 
Getting           ERR                    Returns the code for an error
error-status                             that occurred at run time.
data
                  ERL                    Returns the number of the line
                                         on which an error occurred
                                         (useful only if program has line
                                         numbers).
 
                  ERDEV                  Returns a device-specific error
                                         code for the last device (such
                                         as a printer) for which the
                                         operating system detected an
                                         error.
 
                  ERDEV$                 Returns the name of the last
                                         device for which the operating
                                         system detected an error.
 
Defining your     ERROR                  Simulates the occurrence of
own error                                a BASIC error with a specified
codes                                    error code; can also be used to
                                         define an error not trapped by BASIC.
 
Trapping events   ON event               Specifies a routine to branch to
                                         while a program is running and an
                                         event occurs. An event can occur
                                         when characters are received at a
                                         communications port, a key is
                                         pressed, a lightpen is activated,
                                         an OS/2 protected mode signal is
                                         received, a joystick trigger is
                                         pressed, a specified time has
                                         elapsed, or a user-defined event
                                         has occurred.
 
                  event ON               Enables trapping of the given
                                         event.
 
                  event OFF              Disables trapping of the given
                                         event.
 
                  event STOP             Suspends trapping of the given
                                         event.
 
                  RETURN                 Returns control to the program
                                         after executing an event-handling
                                         subroutine.
 
                  EVENT                  Enable or disable trapping of
                                         events. EVENT OFF and ON are
                                         used to bracket sections of code
                                         where events do not need to be
                                         detected and trapped.