Microsoft KB Archive/44495

= DIALOG Status is Not Reset in Interpreter When Program Ends =

Article ID: 44495

Article Last Modified on 11/21/2006



This article was previously published under Q44495



SUMMARY
In Macintosh QuickBASIC Version 1.00, the DIALOG(1) status is not reset when a program ends. For example, the DIALOG(1) function returns the number of the last button that was pushed from the previous run of the program if a new button has not yet been pushed.

This problem occurs only when you make consecutive runs of a program within the QuickBASIC editor. This is not a problem with compiled programs.

To work around this behavior, you should first check the value of DIALOG(0), which is a &quot;1&quot; if a button was clicked after the program was started. You can then invoke DIALOG(1) to see which button number was clicked.



MORE INFORMATION
The DIALOG(0) function is the central function around which you should design a program to trap a button (or other) event. DIALOG(0) returns the next event in the queue of events that occurred since the last invocation of DIALOG(0), or since the program began.

Note: DIALOG(0) should be invoked only once per cycle in the loop that is polling the value of DIALOG(0). For example, you should let x=DIALOG(0) in the beginning of the loop, and then use &quot;x&quot; in all subsequent IF statements in that loop cycle. This analyzes one event per loop cycle.

Code Example
The following program demonstrates the behavior of DIALOG(1), which works correctly the first time it is run within the editor, but which doesn't work correctly the second time: ' initialize the button: BUTTON 1,1,&quot;Press to END&quot;,(100,100)-(200,200),1 ' THIS WHILE LOOP IS DESIGNED TO WAIT UNTIL THE BUTTON IS  ' PUSHED AND THEN EXIT. IT WILL NOT ENTER THE LOOP IN THE SECOND ' RUN OF THE PROGRAM BECAUSE DIALOG(1) WILL NOT BE RESET TO 0. WHILE DIALOG(1) = 0 initdialog = DIALOG(0) WEND PRINT &quot;END OF PROGRAM&quot; END As a workaround, use the DIALOG(0) function instead of DIALOG(1) to test for button pushes. For example: BUTTON 1,1,&quot;Press to END&quot;,(100,100)-(200,200),1 BUTTON 2,1,&quot;Press to do nothing&quot;,(1,30)-(160,60),1 WHILE NOT ( DIALOG(0) = 1 AND DIALOG(1)= 1 ) WEND PRINT &quot;BUTTON &quot;;DIALOG(1);&quot; WAS PUSHED&quot; PRINT &quot;END OF PROGRAM&quot; END

Additional query words: MQuickB

Keywords: KB44495

-

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

© Microsoft Corporation. All rights reserved.