Microsoft KB Archive/156761

= Microsoft Knowledge Base =

BUG: Notification Fails to Work with STOP, FAIL, and END
Last reviewed: January 10, 1997

Article ID: Q156761

The information in this article applies to:


 * Microsoft Visual Test for Windows 4.0, 4.0a

SYMPTOMS
Notifications do not work more than once if a STOP, FAIL, or END statement is executed in the notification handler routine.

CAUSE
Notifications provide the ability to detect (trap) and respond to a variety of events such as Keystrokes, Window creation, and Window destruction. A notification handler routine gets called every time the corresponding defined event occurs. For example, if the user has implemented a notification handler for a desired keystroke, the script will detect when that key is pressed and will respond by executing the designated code. Notification stops working if a STOP, FAIL, or END statement is executed in its handler routine.

STATUS
Microsoft has confirmed this to be a bug in the Microsoft product listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION
The following sample code demonstrates the above-mentioned problem using the Keypress notification.

Steps to Reproduce Problem
Create a script with the following code:

'$include 'declares.inc'

'Turn the KeyPress notification on - execute KeyPressHandler routine 'when CTRL+C press is detected.

On KeyPress ("C", FCONTROL) Call KeyPressHandler Viewport Clear

Sleep 60 End

'Notification handler subroutine definitions. Every time you press 'CTRL+C, the following sub routine will get called:

Sub KeyPressHandler(vtNotifyData as Variant) static count as long count = count +1 'Print to the viewport that the handler got called Print("KeyPress handler called "); Print("No. of times called: "),count 'The following line is the one mentioned in step 7 'stop End Sub

Desired Functionality

 * 1) Run the Script.
 * 2) Press the CTRL+C keys. This will cause the Keypress handler code to execute.
 * 3) Verify that the handler code was executed by looking for the text "KeyPress handler called" in the Viewport.
 * 4) Repeat step 2 and 3 several times. Be sure to verify that the handler code was executed every time you pressed the CTRL+C keys.
 * 5) The program will end after a minute.

To Cause Failure

 * 1) Uncomment the line that has the STOP command in the Handler routine.
 * 2) Run the Script.
 * 3) Press the CTRL+C keys, and verify that the handler code was executed by looking for the text "KeyPress handler called" in your Viewport.
 * 4) Repeat step 3 several times. Note that the text message in the viewport does not appear repeatedly as before. This indicates that the handler code is not being executed.

Restoring Notifications
To get the notification to work again, you must exit and restart Developer Studio. Then comment out the STOP statement in the error handler before running the script.