1 Reply Latest reply on Jan 27, 2015 5:58 PM by mikebeargie

    OnLastWindowClose, Quitting or closing?


      I'd like to determine whether an OnLastWindowClose script is running because the last window is closing or because FileMaker Pro is quitting.


      It's a similar problem to what's described in this old thread:

      Re: Get Quit-status for use in shutdown-script


      In my shutdown script, my user may need an opportunity to exit the script and run a different script before continuing with the shutdown, which starts a timer after which shutdown continues anyway. The "Exit application" script called by OnLastWindowClose then installs a script timer and exits with a status of false to cancel the current close/shutdown.


      What I need is a way to capture whether a quit or a close was in progress to start with, so that after the countdown, I can resume whatever process was called in the first place.


      I can't use the script parameter technique, because the option isn't available for the OnLastWindowClose trigger.


      Is there some other way to tell the difference between closing the last window and quitting the app?

        • 1. Re: OnLastWindowClose, Quitting or closing?

          The answer is both. OnLastWindow close will fire for both since the action of quitting the program will try to gracefully exit your database before exiting the application.


          This will NOT however be the case if the application crashes or is force quit, then the answer is neither, since the program is interrupted before the OnLastWindow action can fire.


          What you might want to do is open all of your windows without a close option so "close window" is only allowed programmatically via a button you fire. You can then check for last window using the WindowNames design function:



          Basically you don't use the OnLastWindow action, and you script all of your window closes via your own buttons to get complete control.