Microsoft KB Archive/87694

= PRB: Menu Appears, Then Application Exits to Operating System =

Article ID: 87694

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.6a Professional Edition for Macintosh
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q87694





SYMPTOMS
The Microsoft FoxPro menu program works in the development version of FoxPro. However, if you are using the distribution version of the files (a stand-alone executable), the menu appears, then the application exits to the main operating system environment, either MS-DOS, Windows or the Macintosh desktop.



CAUSE
When a menu is generated, running the .MPR file does not put you in an event loop or a wait state.



RESOLUTION
Incorporate a Foundation READ command into the application.

NOTE: Although the Foundation READ can be used in Visual FoxPro, the preferred method is to incorporate a READ EVENT.



Foundation READ
To incorporate a foundation READ command in an application, do the following:

  In FoxPro 2.x, in the Setup section of the menu or program, include the following code: PUBLIC m.xxx m.xxx = .F. In Visual FoxPro, in the Cleanup section of the menu or program, include the following code prior to any other code: READ EVENTS   In FoxPro 2.x, in the Cleanup section of the menu or program, include the following code prior to any other code: READ VALID m.xxx   In FoxPro 2.x, execute the following code when the user chooses the Quit menu option: m.xxx = .T.     CLEAR READ ALL In Visual FoxPro, execute the following code when the user chooses the Quit menu option: CLEAR EVENTS 

For additional information, see the EX1.PJX example in the GOODIES\FNDATION subdirectory and the section on the READ command in the FoxPro version 2.0 &quot;Commands & Functions&quot; or the FoxPro version 2.5 &quot;Language Reference&quot; manual.

