>Hi,
>
>I wrote (or copied it from somewhere) the code below 10 years ago. And now I don't remember it's purpose. This code is called from the method, right after the READ EVENTS, when application is being closed.
>What is the purpose of closing all forms when a user wants to close the application?
>I tried to comment this code and only issue ON SHUTDOWN, after READ EVENTS, and I get no error when some forms are still open. The ON SHUTDOWN seem to close these forms anyways.
>
>
> LOCAL lnForms, i, llDone
> lnForms = _screen.formcount
> FOR i = lnForms to 1 STEP -1
>
> IF TYPE("_SCREEN.Forms(i)") <> "O" OR ISNULL( _SCREEN.Forms(i) )
> LOOP
> ENDIF
>
> IF PEMSTATUS(_SCREEN.Forms(i), 'QueryUnload', 5)
> llDone = _SCREEN.Forms(i).QueryUnload()
> IF !llDone
> RETURN .F.
> ENDIF
> ENDIF
> _screen.Forms(i).Release
> ENDFOR
>
>
>Thank you in advance for any input
Looks like an attempt to regularly close the forms and give them a chance to exit elegantly - no unsaved buffers, no unresolved validations, give the user a chance to click yes on a few buttons. Note that it returns .f. if at least one form's .queryUnload() returns .f. - so if the code in the form returns a „can't close now, look at this!“, then it shouldn't quit in the first place.
That's keeping things neat.