Microsoft KB Archive/46182
Article ID: 46182
Article Last Modified on 11/21/2006
This article was previously published under Q46182
Due to a software problem, you cannot use the UEVENT trapping in conjunction with any other event trapping in the Basic versions listed below. After CALL SETUEVENT is invoked just once, each subsequent non-user-defined event (such as ON TIMER, ON COM, ON KEY, or ON PLAY) also improperly activates the user-defined event (ON UEVENT GOSUB) trap.
Microsoft has confirmed this to be a bug in Microsoft QuickBasic versions 4.0b and 4.5, and in Microsoft Basic Compiler versions 6.0 and 6.0b (buglist6.00, buglist6.00b). This problem was corrected in Microsoft Basic Professional Development System (PDS) version 7.0 for MS-DOS and MS OS/2 (fixlist7.00).
The problem does not apply to QuickBasic versions 4.0 and earlier because they don't support user-defined event trapping (ON UEVENT GOSUB and CALL SETUEVENT).
SETUEVENT improperly activates at the same frequency as the ON TIMER event. This behavior continues to occur until the TIMER OFF statement is used. The problem occurs both in a compiled .EXE program and in the QB.EXE environment. SETUEVENT can be called from another language or from the Basic program itself to reproduce the problem.
The following sample code demonstrates the problem in a compiled .EXE program or in the QB.EXE environment:
' Turn the timer and uevent on: TIMER ON UEVENT ON ' Set up the handler routines for events: ON UEVENT GOSUB ueventhandler ON TIMER(1) GOSUB timerhandler ' Timer event occurs every 1 second. 'Invoke a user-defined event just once: CALL setuevent PRINT "Press any key to end." WHILE INKEY$ = "" WEND END
PRINT "This uevent should only occur once." RETURN
PRINT "A timer event occurred." ' TIMER OFF 'Add this line to work around the problem. RETURN
A key trapping event also causes this behavior, for example:
ON UEVENT GOSUB UEtrap ON KEY(1) GOSUB F1trap UEVENT ON KEY(1) ON PRINT "F1 is trapped. Press enter to trigger Uevent" WHILE INKEY$ <> CHR$(13): WEND 'F1 key will be trapped CALL SetUevent 'trigger Uevent PRINT "Pressing F1 now will cause both events to fire" WHILE INKEY$ <> CHR$(13): WEND 'Pressing F1 now fires both events END UEtrap: PRINT "UEvent trapped" RETURN F1trap: PRINT "F1 trapped" RETURN
In the QB.EXE environment, simply stopping the execution of the program and commenting out the ON TIMER statement fails to stop the activation of the SETUEVENT event during subsequent program runs. For more information on this separate QB.EXE environment problem, query on the following words:
SETUEVENT and buglist4.50
Additional query words: QuickBas BasicCom buglist4.00b buglist4.50 B_BasicCom