4 Replies Latest reply on May 16, 2012 3:44 PM by thosliot

    How to avoid interrupting a timer?

    slraymond

      I have a script which consists only of a Pause/Resume Script step [x seconds], followed by a spoken message. The idea is that a user presses a button which launches the timer, then he does some work in the app, and an alarm sounds at the end of the script's duration.

       

      In testing, I have noticed that the alarm doesn't sound if I have done some work during the script's execution. What events pause or interrupt the Pause/Resume script step, and how can I ensure that the timer will function without interruption?

        • 1. Re: How to avoid interrupting a timer?
          Vaughan

          What do you mean by "done some work"? I assume you mean "do other things in FMP" rather than, say, go outside and dig in the garden or something.

           

          If any script invokes the Halt step then it kills all other scripts dead (qualification: not sure about onTimer invoked scripts).

          • 2. Re: How to avoid interrupting a timer?
            slraymond

            I figured it out. Some buttons in my layout triggered scripts, which interrupted the timer script. Luckily, those scripts were basically only one step (I thought I might expand on them later), so I replaced the scripts with single commands. Thanks!

            • 3. Re: How to avoid interrupting a timer?
              Vaughan

              slraymond wrote:

               

              I figured it out. Some buttons in my layout triggered scripts, which interrupted the timer script. Luckily, those scripts were basically only one step (I thought I might expand on them later), so I replaced the scripts with single commands. Thanks!

               

              That should not necessarily be a problem.

               

              Were the buttons configured to exit or halt the current script? If so, change the button option to "pause".

              • 4. Re: How to avoid interrupting a timer?
                thosliot

                Unfortunately changing the 'some work' button option to pause the current script will cause the alarm script's timed pause to become indefinite; setting it to resume the current script will resume the timed pause when the 'some work' script exits, possibly before the desired interval.

                 

                To maintain, as far as possible, the desired pause before the alarm, I'd use an OnTimer triggered script; so the button (or whatever) that activates the alarm script becomes simply:

                 

                Install OnTimer Script ["Alarm" ; your chosen pause]

                 

                and the Alarm script:

                 

                Install OnTimer ["Alarm"]

                <sound alarm>

                 

                 

                Any other scripted button should use the pause current script option.

                 

                As long as any such button's script is completed before the alarm is due, it will sound at the correct time, otherwise it will sound as soon as the script is completed.

                 

                cheers

                 

                Tom

                 

                Message was edited by: Tom Elliott; added 2nd step to Alarm script