Microsoft KB Archive/33488

= QuickBasic 4.00b UPDATE.DOC: Adds ON UEVENT to Trap Events =

Article ID: 33488

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 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.



New Statement: ON UEVENT
Action: Defines an event trap for a user-defined event

Syntax: ON UEVENT GOSUB { | }

Remarks:

In this syntax, or 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.

Additional query words: QuickBas BasicCom

Keywords: KB33488

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.