4 Replies Latest reply on Dec 17, 2012 11:27 AM by anothersmurf

    FMP12 exits a running script when a database window closes

    anothersmurf

      Summary

      FMP12 exits a running script when a database window closes

      Product

      FileMaker Pro

      Version

      12v3 (Advanced)

      Operating system version

      Mac OS 10.7.5

      Description of the issue

      When running a script in a related database, if that script closes a window, that script stops running, as though it was exited; things that are supposed to happen after the window closes do not happen.

      Steps to reproduce the problem

      Start with two databases, related to each other. DB1 has a script with just 2 steps. The first step runs a script in DB2, the second step beeps.

      The script in DB2 also has just two scripts: Close window [current window] and Halt script.

      In FMP9, if you run the script in DB1, there's no beep. In FMP12, if you run the script in DB2, there's a beep.

      The problem is, in FMP12, when it executes the Close Window step, it just stops running the script in which Close Window was called, it never gets to what follows.

      Now obviously, this isn't my real world example. It's just a demonstration of the problem, much easier to explain than reality. :) But in real life, it's a pretty serious problem.

      (I made a pair of example DBs, I'm really surprised there's no wah to attach them. Seems to me it'd make reproducing the error pretty trivial. If there's some way to attach them that I've missed, or you want me to email them to you, let me know.)

      Expected result

      Closing a window should not exit a script.

      NB it works correctly in FMP9.

      Actual result

      Closing a window exits a script.

      Exact text of any error message(s) that appear

      None

      Configuration information

      None

      Workaround

      None. :(

        • 1. Re: FMP12 exits a running script when a database window closes

               pf:

               Thank you for the post.

                

               Closing a database window doesn't exit a script; however, closing the last window for a database while a script in that file runs does. When a script is called from a related file a "hidden" window is opened in order to allow the script to run, even if the related file is currently closed. 

                

               This behavior has not changed from FileMaker Pro 11 to FileMaker Pro 12. 

                

               Let's say we have two related database files, A and B. File A has script A. Script A reads:

                

               Perform Script ["B" from file: "B"] 

                

               File B has a script B. Script B reads: 

                

               New Window [Style: Document]

               Pause/Resume Script [Indefinitely]

               Close Window [Current Window]

               Beep

                

               Even if you run script A with file B closed, you will hear a beep in both FileMaker Pro 11 and FileMaker Pro 12. 

                

               If you perform this test you will also notice that when the script does the pause step, the current window is titled "B - 2." This is because the window title "B" is hidden. Now instead, modify script B to read:

                

               New Window [Style: Document]

               Pause/Resume Script [Indefinitely]

               Close Window [Current Window]

               Close Window [Current Window]

               Beep

                

               And when the modified script is run, then no subsequent beep is heard because the double "Close Window [Current Window]" will close both "B - 2" and "B" (hidden). Once all the windows of a database file close any scripts in the closed file will end. 

                

               I hope this clarifies the expected behavior, but if not please reply with any questions and I will do my best to answer. 

                

               TSFalcon

               FileMaker, Inc.

          • 2. Re: FMP12 exits a running script when a database window closes
            anothersmurf

                 Well, I downloaded the FMP11 Trial and I can confirm that this behaviour exists in that version as well. (In fact it looks like it changed between 9 and 10.) I'll revise my expectations but I'm stuck with my needs...

                 The workaround I found is to modify the script in the related DB to end with an "exit script" script result, and then modify the calling script to check for that script result. If there's no script result, then I know the related script didn't finish running, and I can halt the calling script before any damage is done.

                 The problem is, I've got dozens of databases, some of which have hundreds of scripts; I'm going to need to check them for external script calls that might not work as they used to (in 9) now that we've upgraded to 12. I have the developer edition of 12, but when I do a design report for my DBs and look at the script section, the list of script steps shows the name of the database a called script is in, but doesn't specify that it's external, so I can't e.g. do a find for "External" to search for all cases in which an external script is called. So if you could suggest a quick way I could search databases for scripts which have external script calls, I'd sure appreciate it.

            • 3. Re: FMP12 exits a running script when a database window closes
              philmodjunk

                   I don't quite see what "damage" you are guarding against with this method that would require incorporating such a check on script results on each and every externally performed script.

              • 4. Re: FMP12 exits a running script when a database window closes
                anothersmurf

                     Phil-- Of course it depends on the script. Every externally called script is potentially affected by this issue (if that script closes a window and then does something else, it's affected). Of course not every externally called script does that, but every one needs to be checked to see whether it does.

                     Without getting into overcomplicated specifics, my real world example of this had an externally called script which, depending on conditions, might close the window and then halt scripts. Because of the way FMP 10+ handles this situation, the halt never happens, and the script that called the externally called script continues running. In other words, because one script stops when it isn't supposed to, another script doesn't stop when it is supposed to. Which can make quite a mess, depending on what that script does beyond the point where it was supposed to stop.