>>LOCAL lnForm, lnFormToClose >>lnFormToClose = 1 >>FOR lnForm = 1 TO _screen.FormCount >> IF TYPE("_screen.Forms(lnFormToClose)") == "O" >> IF _screen.Forms(lnFormToClose).QueryUnload() >> _screen.Forms(lnFormToClose).Release() >> ELSE >> RETURN .F. >> ENDIF >> ELSE >> lnFormToClose = lnFormToClose + 1 >> ENDIF >>ENDFOR >>CLEAR EVENTS >>DO cleanup >>>>...and Cleanup does CLOSE DATABASES, CLEAR ALL, SET CLASSLIB TO, and so forth.
>LOCAL lnForm, lnCount >lnCount = _screen.FormCount >FOR lnForm = 1 TO lnCount && have to do this because formcount > && changes every time you close a form > IF TYPE("_screen.Forms(lnForm)") == "O" && might also test to see if > && BASECLASS property is "FORM" > IF _screen.Forms(lnForm).QueryUnload() > _screen.Forms(lnForm).Release() > ELSE > RETURN .F. > ENDIF > ENDIF >ENDFOR >CLEAR EVENTS >DO cleanupI was thinking of moving the File - Exit code to a procedure and having the menu just call the procedure. Then I would also have ON SHUTDOWN DO the procedure. Is there any reason why File - Exit and ON SHUTDOWN shouldn't call the same code? I think not, but I wondered if there is a catch here.