3 Replies Latest reply on Oct 22, 2013 12:33 PM by philmodjunk

    Can Script B interrupt Script A?

    vfoecke

      Title

      Can Script B interrupt Script A?

      Post

           Let's say I have a script A (triggered when a user clicks a button)  that takes some time to finish running (10 - 20 seconds).

           Is it possible for another script B (triggered by a different button) to "interrupt" script A?

           I have only found that it is possible if script A is currently paused at a Pause Script command.

           Is there any OTHER point where a script might be interrupted (such as when script A opens or closes a window, loads a record, commits a record, etc.)

           I ask because my user (who happens to be very fast on the touch screen monitor) is reporting some strange behaviors that I can only "suspect" could be caused by some script possibly interrupting another.  He reports that he sometimes gets left on a layout that script B NEVER visits.  I'm trying to prove or disprove a thought that maybe script A was previously left "dangling" after being interrupted.  It's quite rare and I can't reproduce it, but I have watched it happen.  I'm just grasping for a possible direction to steer my troubleshooting.

        • 1. Re: Can Script B interrupt Script A?
          philmodjunk

               I'd guess that your user's reports stem from a script that is tripping a script trigger that then interferes with the correct function of the original script.

               A script could halt or pause a script that is currently running. If you add a button to a layout, note the button options in Button set up that can halt, pause, exit or resume the "current script".

               Halt script is also a script step so any script that terminates with "Halt script" also halts any other script that may also be running or paused.

          • 2. Re: Can Script B interrupt Script A?
            vfoecke

                 I've tested the various options (Pause, Resume, Exit, and Halt) associated with a button.  I have confirmed what the documentation states, namely that these options control what will happen to a script that is ALREADY PAUSED when this button is pressed.  It does NOT say that pressing the button will cause a currently running script to be paused.  In fact, I have confirmed that pressing the button does not cause a running script to pause.  In that case, pressing the button is simply ignored.

                 Does the first paragraph of your reply suggest that tripping a script trigger will cause the triggered script to take precedence over a currently running script (which is not possible with a button-triggered script)?  I can't find that documented anywhere.  If that is indeed possible, I need to understand what happens to the interrupted script.  Is it:
                   a) paused, never to resume again
                   b) suspended temporarily, then resumed when the triggered script completes (possibly in some unexpected environment)
                   c) trying to muddle along simultaneously (with possibly bizarre behavior resulting from both scripts
                   d) something else??

            • 3. Re: Can Script B interrupt Script A?
              philmodjunk
                   

                        Does the first paragraph of your reply suggest that tripping a script trigger will cause the triggered script to take precedence over a currently running script?

                   Yes. When a script trips a script trigger, the current script is paused and the trigger controlled script begins executing. When execution completes--provided that no Halt Script was executed, control returns to the original script, but now a completely unexpected record and/or layout may be "current" from what was the case before the trigger was tripped.

                   This is easily observed if you step through the first script in FileMaker Advanced's script debugger and watch what happens when it trips such a script trigger.