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

Geoff Canyon geoff at runrev.com
Mon May 30 03:03:12 EDT 2005


I originally went with polygon graphics, which put me at about twenty  
lines of code by your way of counting (including "on" and "end"  
statements).

Switching to oval graphics I got it down to 11 lines, which sweep  
both the hour and minute hands. But the second hand is jumpy. Simply  
using send...in just about always results in the second hand either  
taking noticeably too long or too short to measure a second here or  
there. So I added code to time seconds more finely. This results in  
the second hand always ticking when it's supposed to. The display  
shows the long seconds, and you can watch the updates hit  
consistently in the first tenth of a second or so. It puts me up at  
18 lines of code, but the result is worth it I think:

on openCard
   setTime
end openCard

local sTime
on setTime
   put word 1 of the long time into tTime
   if tTime is sTime then
     send "setTime" to me in 5 ticks
     exit setTime
   end if
   put tTime into sTime
   put sTime && the long seconds into fld "time"
   set the itemDelimiter to ":"
   set the startangle of grc "hour" to 90 - (30 * item 1 of sTime) -  
(item 2 of sTime) / 2
   set the startangle of grc "minute" to 90 - (6 * item 2 of sTime) -  
(item 3 of sTime) / 10
   set the startangle of grc "second" to 90 - (6 * item 3 of sTime)
   send "setTime" to me in 50 ticks
end setTime


The stack is available by executing this in the message box:

go stack url "http://www.inspiredlogic.com/rev/clock.rev"

On May 27, 2005, at 4:08 PM, Malte Brill wrote:

> Sorry, couldn´t resist
>
> on mouseUp
>   if the flag of me is empty then set the flag of me to false
>   set the flag of me to not the flag of me
>   if the flag of me then startClock
> end mouseUp
>
> on startclock
>   put the long time into myTime
>   put myTime into fld 1
>   set the itemdel to ":"
>   put char 1 to 2 of item 3 of myTime into daSecs
>   set the startAngle of grc "seconds" to 90-dasecs*6
>   put item 2 of myTime into daMinutes
>   set the startangle of grc minutes to 90-daminutes*6
>   put item 1 of myTime into daHours
>   set the startAngle of grc "hours" to 90-dahours*30-daminutes*30/60
>   if the flag of me then send startClock to me in 500 milliseconds
> end startclock
>
> Cheers,
>
> Malte
>
> Create 3 oval graphics
> set arcangle of each graphic to zero
> loc of all 3 needs to be the same
> 1 field to put the time in
>
> Cheers,
>
> Malte
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list