Countdown HH:MM:SS
James Hurley
jhurley0305 at sbcglobal.net
Thu Jul 21 06:29:26 EDT 2011
>
> Message: 15
> Date: Wed, 20 Jul 2011 15:19:07 -0400
> From: Roger Eller <roger.e.eller at sealedair.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Subject: Re: Countdown HH:MM:SS
> Message-ID:
> <CAAT6EXPFGQY-=S6irWxERo3BXK=Ftn5y+bJdn55pLqvz3LKh8g at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Wed, Jul 20, 2011 at 1:06 PM, Ken Ray wrote:
>
>>> Using the dateItems is definitely the right direction, but my objective
>> is
>>> to count backwards from for example; 2 hours, 45 minutes, and 59 seconds
>>> while updating the display field every second. When the countdown
>> reaches
>>> 00:00:00, I would play a sound of do other actions.
>>
>> Sorry about that... this will work if you just want to count down from a
>> fixed amount of time:
>>
>> on mouseUp
>> DoCountDown "2:45:59"
>> end mouseUp
>>
>> on DoCountDown pTime
>> convert pTime to seconds
>> subtract 1 from pTime
>> convert pTime to dateItems
>> split pTime by ","
>> put format("%02d:%02d:%02d",pTime[4],pTime[5],pTime[6]) into tNewTime
>> put tNewTime into fld "Time"
>> if tNewTime = "00:00:00" then
>> TimesUp
>> else
>> send "DoCountDown tNewTime" to me in 1 second
>> end if
>> end DoCountDown
>>
>> on TimesUp
>> answer "Done"
>> end TimesUp
>>
>> Ken Ray
>> Sons of Thunder Software, Inc.
>> Email: kray at sonsothunder.com
>> Web Site: http://www.sonsothunder.com/
>>
>>
> 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
>
Roger,
Good decision. Ken's solution is MUCH cleaner.
Jim Hurley
More information about the use-livecode
mailing list