QuickBasic 4.00b UPDATE.DOC: Enhanced ON ERROR Handling (33486)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0

This article was previously published under Q33486

SUMMARY

The following information was taken from the QuickBasic Version 4.00b UPDATE.DOC file. It describes features that have been added since Microsoft QuickBasic Version 4.00 was released.

This information applies to Microsoft QuickBasic Versions 4.00b and 4.50 for MS-DOS, to Microsoft Basic Compiler Versions 6.00 and 6.00b, and and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.

MORE INFORMATION

Microsoft QuickBasic Versions 4.00b and later and Basic compiler 6.00b and later include an important new error-handling feature for multiple-module programs.

In previous versions of QuickBasic, an error in a module that did not contain an error handler caused the program to terminate immediately, even if an error handler was present in a different module. QuickBasic 4.00b first looks for an active error handler in the module where the error occurred, then in the module that invoked that module, and so on. QuickBasic follows the chain of procedure invocations back until it finds an active error handler or reaches the program's main module. If QuickBasic cannot find an error handler by this process, the program terminates with an error message.

Note that if the error occurs in an event-handling routine, however, QuickBasic does not search for an error handler beyond the module that invoked the event handler.

This feature affects the behavior of the RESUME statement. In previous versions of QuickBasic, RESUME caused the program to resume execution at the "current statement," meaning the statement that caused the error. In a QuickBasic 4.00b multiple-module program, however, the "current statement" is the last executed statement in the module containing the active error handler.

The new error-handling feature has a similar effect on the ERL function. In QuickBasic 4.00b, the program line that the ERL function identifies as the source of an error is the line that contains the last executed statement in the module where the active error handler is located.

Modification Type:MinorLast Reviewed:1/9/2003
Keywords:KB33486