Timer Pause script
Sarah Reichelt
sarah.reichelt at gmail.com
Fri Jul 9 19:38:44 EDT 2010
The problem is that the global variable startSeconds keeps the same value so when you restart the timer after a pause, you need to reset the startSeconds to the current seconds less the time already on the timer.
Cheers,
Sarah
Sent from my iPad
On 10/07/2010, at 8:34 AM, JosepM <jmyepes at mac.com> wrote:
>
> Hi,
>
> I'm blocked :( with this...
> I try to start and stop a timer but with a pause button to pause the time
> and continue again once the pause button is pressed again.
>
> I have two buttons, button "b_timming" and button "b_pause"
> Also some graphics to show the button icons and display.
> The start and stop it's fine, but I don't see how pause and continue where
> the time was stoped...
>
> Salut,
> Josep
>
> Script for button "b_timming"
>
> Local tDuration, lTime
> Local lStart
> Global gPause,startSeconds
> on mouseUp
>
> if lStart is 1 then
> # Stop time
>
> set the visible of graphic "gr_play" to false
> set the visible of group "gr_pause" to false
> put false into gPause
> set the icon of button "b_timming" to 1023
> set the hiliteicon of button "b_timming" to 1024
>
> put 0 into lStart
> put lTime into fld "countdown"
> answer lTime
> else
> # Start time
>
> set the visible of graphic "gr_play" to true
>
> set the icon of button "b_timming" to 1012
> set the hiliteicon of button "b_timming" to 1013
>
> put 1 into lStart
> put the seconds into startSeconds
>
> updateProgress
> end if
> end mouseUp
>
>
> on updateProgress
> if lStart is 1 then
> if gPause is false then
> set the visible of group "gr_pause" to false
>
> put (the seconds - startSeconds) into tElapsed
>
> put padNum(tElapsed div (60*60)) into tHours
> put padNum(tElapsed div 60) into tMins
> put padNum(tElapsed mod 60) into tSecs
>
> put tHours & ":" & tMins & ":" & tSecs into fld "countdown"
> put tHours & ":" & tMins & ":" & tSecs into lTime
> put 0 into tElapsed2
> send updateProgress to me in 5 ticks
> else
> set the visible of group "gr_pause" to true
> end if
> end if
> end updateProgress
>
> # this function just makes the time units look pretty by inserting a zero
> before single digits
> function padNum pNum
> if the length of pNum = 1 then
> return "0" & pNum
> else
> return pNum
> end if
> end padNum
>
> Script for button "b_pause"
>
> Global gPause,startSeconds
>
> on mouseUp
> if gPause is true then
> put false into gPause
> send "updateProgress" to button "b_timming" in 5 ticks
> else
> put true into gPause
> put the seconds into startSeconds
> end if
>
> end mouseUp
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Timer-Pause-script-tp2284161p2284161.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list