QuickBasic 4.00b UPDATE.DOC: Adds ON UEVENT to Trap Events (33488)



The information in this article applies to:

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

This article was previously published under Q33488

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.00b, and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.

MORE INFORMATION

New Statement: ON UEVENT

Action: Defines an event trap for a user-defined event

Syntax: ON UEVENT GOSUB {<linenumber>|<linelabel>}

Remarks:

In this syntax, <linenumber> or <linelabel> specifies the number or label of the first line in the event-trapping subroutine. The ON UEVENT statement allows your program to branch to an event-trapping subroutine when a user-defined event occurs. ON UEVENT is unlike other event-trapping statements in that it allows your program, not an external agent, to trigger the event that you expect to trap. For example, assume that your system contains a data acquisition device that generates an interrupt when data arrives. Most of your application is written in QuickBasic. The main module contains an event-trapping subroutine that responds to a user-defined event (in this case, the arrival of data from the acquisition device). The following three assembly-language procedures are also linked into the program:

  1. An interrupt handler that responds to the interrupt generated by the acquisition device
  2. A routine that installs the interrupt handler in the chain of interrupts
  3. A routine that removes the interrupt handler from the chain of interrupts
When the program begins, it calls the assembly-language routine that installs the interrupt handler. Then it executes an ON UEVENT statement to identify the QuickBasic subroutine that will be executed when a user-defined event occurs. The final step in setting up the user-defined event trap is to execute a UEVENT ON statement. Once this is done, the Basic program enters its main execution loop.

When data arrives, the acquisition device generates an interrupt. The assembly-language interrupt handler, in turn, calls the routine SetUEvent. SetUEvent is a Basic run-time-library routine that causes a user-defined event to occur in Basic. This special routine can be called from any Microsoft language. References to SetUEvent are resolved when your program is linked with the run-time library. The user-defined event causes the program to branch to the QuickBasic subroutine identified by the previous ON UEVENT statement. At this point, the event-trapping subroutine performs whatever processing is desired. Just before the application terminates, it calls the assembly-language routine that removes the interrupt handler from the chain of interrupts.

New Statements: UEVENT ON, OFF, STOP

Action: Enable, disable, or suspend event trapping for a user-defined event

Syntax: UEVENT ON
UEVENT OFF
UEVENT STOP

Remarks:

The effect of UEVENT parallels that of other event-trapping statements. For example, UEVENT ON enables a user-defined event trap that you previously set up with an ON UEVENT GOSUB statement.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB33488