8 Replies Latest reply on Dec 14, 2015 9:27 AM by BruceRobertson

    On Last Window Close

    cowens1

      Background:

      Users close last window not meaning to close themselves out of the file.

      Remedy:

      Use a 'SHOW CUSTOM DIALOG" script asking if they really want to quit the file. If Cancel is selected, then stop the exit.

       

      Sounds straight forward enough, but I cant get past the Show Custome Dialog part. Everything I've tried ends up witht he file still closing.

       

      Any suggestions will be greatly appreciated!

       

      Collins W Owens

        • 1. Re: On Last Window Close
          GAmstutz

          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]

          end if

           

          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]

          end if


          - Gary Amstutz

          iOS Development Solutions

          • 2. Re: On Last Window Close
            cowens1

            Thankyou!

            Marking the result "False" is what I had failed to do.

             

            Very helpful!

             

            Thanks again,

             

            Colliins

            • 3. Re: On Last Window Close

              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.

               

              such as

              Script A

              Close Window

               

              Script B

              Close Window

              If get( ScriptResult) is False or whatever

                do something

              else

              xxx

              end if

               

              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.

               

              Rejoinders?

              • 4. Re: On Last Window Close
                BruceRobertson

                You might want to read the question.

                And then read the correct, previous answer.

                Your method does not solve the problem.

                • 5. Re: On Last Window Close

                  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

                   

                  if backup

                  perform local backup script

                  ...continue

                  else if cancel

                  exit script() or halt script

                  else

                  ....continue

                  end if

                   

                  My point was, maybe not clear, that Exit Script [ result: False], the False is not needed.

                  • 7. Re: On Last Window Close

                    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...

                    • 8. Re: On Last Window Close
                      BruceRobertson

                      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.