>Like everyone else I start applications with a .PRG which sets the environment, displays a splash screen, loads a menu system, etc. I check to see if the user is a valid user. if not I display a message and then I would like to exit the application. To exit I have a function called "Depart". When I do Depart the application does not close. What can I add to make the app close?
>
>*-------------------------------------------------------------------------------
In addition to Barbara's recommendation, if you are creating any objects that might not get released and could be actively executing, you may need to release them as well. If you're really exiting, you need to release all Forms and objects - dangling object references may be an issue as well. At a minimum, I'd try explicitly releasing all Forms in the _SCREEN.Forms collection, either with a FOR...NEXT loop that decrements, or something like:
FUNCTION Depart
LPARAMETER tlNoDebug
CLEAR EVENTS
POP KEY ALL
SET ASSERTS ON
ON SHUTDOWN
DEACTIVATE WINDOW ALL
_SCREEN.Hide()
SET SYSMENU TO DEFAULT
SET LIBRARY TO
ASSERT _SCREEN.Show() AND ''=SYS(3056) AND tlNoDebug 'Forms Deactivated'
WITH _SCREEN
DO WHILE .FormCount > 0
.Forms(.FormCount).Release()
ENDDO
ENDWITH
ASSERT tlNoDebug 'Forms Released'
RETURN .F.
With dangling object refs, you still may need a CLEAR ALL
>function Depart
>
>clear events
>deactivate window all
>pop key all
>on shutdown
>
>if _VFP.StartMode = 0 && Development Mode
> set sysmenu to default
> set library to
> modify window screen
> =sys(3056) && Reread Registry and config.vfp settings
>endif
>
>return .F.
>*-------------------------------------------------------------------------------