Draw a clock: Difference between revisions

no edit summary
({{header|GUISS}})
No edit summary
Line 156:
window.setInterval(update_clock, 200);
}</lang>
 
=={{header|Liberty BASIC}}==
LB has a timer to call a routine at regular intervals. The example is a cut-down version of the full clock supplied with LB as an example.
<lang lb>
WindowWidth =120
WindowHeight =144
nomainwin
 
open "Clock" for graphics_nsb_nf as #clock
#clock "trapclose [exit]"
#clock "fill white"
for angle =0 to 330 step 30
#clock "up ; home ; north ; turn "; angle
#clock "go 40 ; down ; go 5"
next angle
 
#clock "flush"
 
timer 1000, [display]
wait
 
[display] ' called only when seconds have changed
time$ =time$()
seconds =val( right$( time$, 2))
' delete the last drawn segment, if there is one
if segId >2 then #clock "delsegment "; segId -1
' center the turtle
#clock "up ; home ; down ; north"
' erase each hand if its position has changed
if oldSeconds <>seconds then #clock, "size 1 ; color white ; turn "; oldSeconds *6 ; " ; go 38 ; home ; color black ; north" : oldSeconds =seconds
' redraw all three hands, second hand first
#clock "size 1 ; turn "; seconds * 6 ; " ; go 38"
' flush to end segment, then get the next segment id #
#clock "flush"
#clock "segment"
input #clock, segId
 
wait
 
[exit]
close #clock
 
end
</lang>
 
=={{header|Tcl}}==
Anonymous user