here is the CLOCKFACE script...coded in 3 MINUTES...17 LINES of CODE

Dennis Brown see3d at writeme.com
Wed Jun 8 12:35:28 EDT 2005


Geoff,

Your new idea gave me an idea.  Make three handlers --one for each  
hand (I hope I got the hour math straight)
You can find it in my user space (see3d).

Dennis

on openCard
   setSeconds; setMinutes; setHours
end openCard

on setSeconds
   send setSeconds to me in 1-(the long seconds mod 1) seconds
   put the long time into fld "Time" --8:13:15 AM
   set the angle of grc "Second" to 450 - ((the seconds * 6) mod 360)
end setSeconds

on setMinutes
   send setMinutes to me in 10-(the seconds mod 10) seconds --10  
seconds/degree
   set the angle of grc "Minute" to 450 - ((the seconds mod 3600) div  
10)
end setMinutes

on setHours
   send setHours to me in 120-(the seconds mod 120) seconds --120  
seconds/degree
   set itemdel to ":"
   set the angle of grc "Hour" to 450-(60*item 1 of the time mod 12)  
- ((the seconds mod 3600) div 120) --It's UTC if you just use the  
seconds here
end setHours

On Jun 8, 2005, at 10:04 AM, Geoff Canyon wrote:

> I came up with a radically different approach. Several iterations  
> ago, we realized that we didn't have to guess when it would be time  
> to set the clock graphics. We could use 1-(the long seconds mod 1)  
> to get a message sent exactly when we need it.
>
> Well, we're still guessing at when it's time to move the minute  
> hand or the hour hand, and we don't need to. The minute hand moves  
> one degree every ten seconds, the hour hand one degree every two  
> minutes. The tests to determine this are simple. The natural thing  
> to do is set the second hand, check to see if the minute hand needs  
> to be set, and if it does check to see if the hour hand needs to be  
> set. At each step, I want to exit if appropriate. The stumbling  
> block was the send...in. I need to get to the end to do it.
>
> Then I realized -- the send...in doesn't have to be the last step.  
> It can come at any point. So here's the script now:
>


More information about the use-livecode mailing list