2 Replies Latest reply on Aug 26, 2013 6:46 PM by terrytaylor

    How can I exit a running script (loop) with a script button or script trigger?

    terrytaylor

      I've been struggling with this off and on for several days and just can't make it work. I'm sure someone here can steer me in the right direction.

       

      My wife teaches at a local university where students must memorize a lot of "pieces" of information. So I've developed an iPad app to help them learn a lot of material quickly and easily. One aspect of the app is a hands-free automatic slide show with Start and Stop buttons. I also have Pause and Resume buttons/functions, but I've set them aside until I get the Start and Stop functions operating correctly. The time interval between slides is adjustable via script variables, in one-second increments. I'm using a loop to cycle through the found set of records. Everything works perfectly except for the Stop script which is intended to exit and cancel the Start Slide Show script.

       

      I've tried several approaches, but my latest method declares a $$slidestate variable to "Run" the slide show. When the last record loads, the loop is exited and the script ends. No problem, works as intended. To stop the show in progress, I declare a new $$SlideState variable with another script, to exit the loop and stop the running slide show script. It almost works... the Stop script completes and exits, and then returns control to the slide show script... which continues to the pause step and freezes. The Data Viewer shows that the $$SlideState variable is changed to "Stop." When I step through with the Debugger, all works well as long as I keep clicking.

       

      I've tried basically the same approach with global fields in place of the variables, and got the same results. I started off without If statements, and then included them... Same results. I also tried Halt instead of Exit, but I've had trouble with Halt Script stopping other scripts, especially when it is attached to a script trigger. In addition to a Stop button, I'll need to call my "Stop" script with a trigger, since a user is likely to leave the layout or select another script button while the slide show is still running. That would create a whole new set of problems.

       

      I'm no scripting expert, but I thought this would be fairly straightforward. In any case, I'm stumped.

       

      Hope someone can help me see the light. Please accept my thanks in advance.

       

      I've attached my Slide Show script for your review. The current iteration of my Stop script is simply one line: Set Variable [$$SlideState; Value: "Stop"]

       

      I'm using FMP 12 Advanced and FM 12 Go.

       

      Terry

       

      Slide Show Script.jpg