Countdown HH:MM:SS
Nonsanity
form at nonsanity.com
Wed Jul 20 16:34:51 EDT 2011
Or with the other features you mentioned:
on mouseup -- start 1 hour timer button
get the seconds
put it into now
convert now to internet date
put now into fld 1 -- display the current time
add 3600 to it -- one hour from now
set the targetTime of me to it
convert it to internet date
put it into fld 2 -- display the target time
UpdateCountdown
end mouseup
on UpdateCountdown
get the targetTime of me
if it is empty then exit UpdateCountdown
put CountdownCalc( it ) into res
if char 1 of res is "-" or res = "0:00:00" then
-- timer ended
set the targetTime of me to empty
put "0:00:00" into res
end if
put res into fld 3 -- display the countdown
-- always best to make sure this timer loop hasn't already been started
if "UpdateDountdown" is not in the pendingmessages then send
"UpdateCountdown" to me in 1 second
end UpdateCountdown
function CountdownCalc targetTime -- in seconds
put targetTime - the seconds into deltaTime
put trunc(deltaTime / 3600) into h -- hours
put trunc((deltaTime - (h * 3600)) / 60) into m -- minutes
put deltaTime - (h * 3600) - (m * 60) into s -- seconds
put format( "%01i:%02i:%02i", h, m, s ) into countdown
return countdown
end CountdownCalc
on MouseUp -- cancel button
set the targetTime of me to empty
end MouseUp
~ Chris Innanen
~ Nonsanity
> On Wed, Jul 20, 2011 at 3:19 PM, Roger Eller <roger.e.eller at sealedair.com>wrote:
>
>>
>> With only a few tweaks like handling a cancel/reset request, this script
>> does what I need. James' was almost the one, but the time wasn't starting
>> from a pre-set amount of time such as 1 hour, etc. Thanks to everyone
>> that
>> contributed!
>>
>> ~Roger
>>
>
More information about the use-livecode
mailing list