Question:
I have built an executable file and included a READ EVENTS command. After running the .exe, I am unable to quit VFP. The message I get reads: “Cannot quit FoxPro.”
Answer:
VFP cannot quit when a READ EVENTS command is active. Therefore you must perform a CLEAR EVENTS before the QUIT command when you want to leave an application. Users can also try to end a VFP application by clicking on the close box on the application window. Therefore you will need to trap this by putting a CLEAR EVENTS command into the ON SHUTDOWN routine of the application.
Create a program with the following code, compile it to an EXE, and run the EXE. Click on the close box of the application to test the ON SHUTDOWN behavior:
ON SHUTDOWN Do MyShutDownRoutineON KEY LABEL F2 CLEAR EVENTSwait wind nowait "Press F2 to clear events"READ EVENTSPROC MyShutDownRoutineCLEAR EVENTSENDPROC