Timer Pause script
JosepM
jmyepes at mac.com
Fri Jul 9 18:34:13 EDT 2010
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.
More information about the use-livecode
mailing list