I hate to admit it, but I'm not sure of the proper way to QUIT. Nor am I sure of the READ EVENTS, CLEAR EVENTS relation and the placement of code before, after or between. Where is the best place to put the QUIT command? These questions came up after adding some suggested code to make things better. Here's a stripped down example:
*** MAIN.PRG
ON SHUTDOWN Do ProperShutDown
*** START PROGRAM
DO FORM First NAME frmFirst LINKED
READ events
CLEAR EVENTS
*** End of Program
**********************************
PROCEDURE ProperShutDown
**********************************
ON SHUTDOWN
CLEAR ALL
CLOSE ALL
IF _vfp.StartMode = 0
CANCEL
ELSE
QUIT
ENDIF
ENDPROC && ProperShutDown
********* CODE In FrmFirst.Command1.CLICK
** I experimented with these 4 commands
RELEASE ThisForm
** With just Release ThisForm, the program ended, but none
** of the 'SHUTDOWN code' from the main.prg fired and I
** have to go to PROGRAM on menu bar and click on CANCEL
QUIT
** Adding Quit almost worked. but got an error saying
**could not CLEAR ALL because COMMAND1 was in use.
CLEAR EVENTS
** adding CLEAR EVENTS seems to work fine. 'SHUTDOWN code'
** is fired. Do not have to go to PROGRAM on menu bar and
** click on CANCEL
CANCEL
** adding CANCEL ends the program. I do not have to click
** on CANCEL under PROGRAM. But the 'SHUTDOWN code' does
** not fire.
Is using the CLEAR EVENTS command the proper way to end the form and return control to MAIN.PRG ? Is there another prefered way. When would you place code between READ EVENTS and CLEAR EVENTS?
Jim Rumbaugh
*** MAIN.PRG
ON SHUTDOWN Do ProperShutDown
*** START PROGRAM
DO FORM First NAME frmFirst LINKED
READ events
CLEAR EVENTS
*** End of Program
**********************************
PROCEDURE ProperShutDown
**********************************
ON SHUTDOWN
CLEAR ALL
CLOSE ALL
IF _vfp.StartMode = 0
CANCEL
ELSE
QUIT
ENDIF
ENDPROC && ProperShutDown
********* CODE In FrmFirst.Command1.CLICK
** I experimented with these 4 commands
RELEASE ThisForm
** With just Release ThisForm, the program ended, but none
** of the 'SHUTDOWN code' from the main.prg fired and I
** have to go to PROGRAM on menu bar and click on CANCEL
QUIT
** Adding Quit almost worked. but got an error saying
**could not CLEAR ALL because COMMAND1 was in use.
CLEAR EVENTS
** adding CLEAR EVENTS seems to work fine. 'SHUTDOWN code'
** is fired. Do not have to go to PROGRAM on menu bar and
** click on CANCEL
CANCEL
** adding CANCEL ends the program. I do not have to click
** on CANCEL under PROGRAM. But the 'SHUTDOWN code' does
** not fire.
Is using the CLEAR EVENTS command the proper way to end the form and return control to MAIN.PRG ? Is there another prefered way. When would you place code between READ EVENTS and CLEAR EVENTS?
Jim Rumbaugh