>>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 cleanupWhy would I want to test to see if .BaseClass property = "FORM"? If the object exists and is in _SCREEN.Forms() what else could it be? If it's a formset, I still want to .QueryUnload() and .Release(), right? By the way, I don't remember where this code came from, but I'm pretty sure I didn't write it, so there may be ramifications I don't understand. Also, my users probably never use the menu to close the app anyway, so the code might not have been run enough to expose its bugs.