I assume you've set a script Trigger from the File Info window for the "onLastWindowClose", and you already know how to do this (and thus your title to this post).
Simply put up a custom dialog and ask if they want to close your custom system. I'd make "Close" the default (option #1) if you think most of your users will be closing this intentionally when they close the last window, since this is the default behavior, and make the non-default option (#2) the "Cancel" button, which will leave your system open and running.
If your "Cancel" button is item #2, then do the following:
If [ Get(LastMessageChoice) = 2]
Exit Script [ result: False]
However, if your system is on 24/7 and your users would rarely close the database for any reason, then I'd make the default (item #1) the "Cancel" button and "Close" item #2.
You'd then write something like this near the beginning of your onLastWindowClose script:
If [ Get(LastMessageChoice) = 1]
Exit Script [ result: False]
- Gary Amstutz
Marking the result "False" is what I had failed to do.
Mine works without having to mark it as false.
The only time I give exit script a value is when I want to use get script result in the script that performed the current script as a test for what to do next.
If get( ScriptResult) is False or whatever
In Script A the exit/halt script only serves to stop the closing of the file.
In Script B it gives an option to do something else
If you are using close button with out a script, then it doesn't really matter as nothing will get the result.
You might want to read the question.
And then read the correct, previous answer.
Your method does not solve the problem.
I did. Perhaps my post wasn't clear.
I use the same script but do not use a parameter in the Exit Script() as I was trying to explain, it isn't needed.
I use Halt Script which stops all pending scripts but that may not be OK with some situations.
Actually I use the close script like this
On last window close
Dialog Do you want to backup, exit, cancel
perform local backup script
else if cancel
exit script() or halt script
My point was, maybe not clear, that Exit Script [ result: False], the False is not needed.
Thanks. I stand corrected on exit script(false)
I've always used Halt Script since I don't stack any scripts by pausing a running script after clicking a button to run another. If scripts are stacked then the exit script(false) might allow those stacked scripts to continue running.
For instance a long winded update script is in process but the user clicks the exit button. Exit script would be good as an Ooops button to return to the running update.
In a multi-active running window program like 4th Dimension I had to script an exit to determine if any window was running a script as every window could be running a script. Filemaker is one script at a time (except for server side scripts) so a button has to pause a script to run on top of another script.
Glad I misspoke in this thread as I learned something...
Glad it helped.
Exit script false is useful in lots of situations, particularly with (some) script triggers, where exit script false will cause the original event to "not happen". For example, it can be used with onKeystroke script triggers.