Analog Clock
Has buttons to stop and start the clock.
The clock is displayed every second showing the hour,minute, and second hand.

' ---------------------------------------
' Analog clock
' ---------------------------------------
html " <script type='text/javascript'>
<!--
var a = null;
var aa = null;
var intervalId = 0;
function startTimer()
{
    var as = document.getElementsByTagName('A');
    if (intervalId == 0)
    {
        for (var i = 0; i < as.length; i++)
        {
        if (as[i].firstChild.data == 'Next')
            {
            a = as[i];
            break;
            }
        }
    if (a) intervalId = window.setTimeout('window.location = a.href', 1000);
    }
}
function stopTimer ( )
{
    clearInterval ( intervalId );
    intervalId = 0;
}
//--></script>"
 
html "<CENTER><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=40% bgcolor=tan><TR align=center><TD>"
link    #next, "Next", [next]
    #next cssclass("sBtn")
html "</TD><TD>"
link    #play, "Play", [play]
    #play cssclass("sBtn")
html "</TD><TD>"
link    #pause, "Pause", [pause]
    #pause cssclass("sBtn")
html "</TD></TR></TABLE>"
' gimme someplace to display with a pannel id of pid
pid$ = "pid"
html "<table border=1><tr><td id=";pid$;">circle here</td><tr><table>"
gosub [d2]
wait
 
[next]
gosub [d2]
wait
 
[pause]
if playing <> 0 then stopIt = 1
playing = 0
html "<script> stopTimer();</script>"
wait
[play]
if playing = 0 then
    playing = 1
    html "<script> startTimer();</script>"
end if
wait
 
' --------------------------------------------
' clock. I got nothing but time
' ---------------------------------------------
[d2]
if playing = 1 then goto [shoTime]
n    = 12 ' num of points
r    = 95 ' radius
pi    = 22/7
alpha    = pi * 2 / n
dim points(n)
graphic #g2, 200, 200
' --------------------------------------
' Draw the clock
' --------------------------------------
#g2 size(2) 'pen size
#g2 down()
#g2 font("arial", 20, "bold")
#g2 place(85,30)
#g2 "\12"
#g2 place(170,105)
#g2 "\3"
#g2 place(10,105)
#g2 "\9"
#g2 place(90,185)
#g2 "\6"
for i = 0 to n - 1
    theta = alpha * i
    px = cos( theta ) * r
    py = sin( theta ) * r
    px = px + 100
    py = py + 100
    #g2 place(px,py)
    #g2 circle(2)
next i
 
[shoTime]
'
' clear previous sec,min,hr
'
r    = 63
p    = se
#g2 color("white")
gosub [h2Dot]
r    = 50
p    = mi
#g2 color("white")
gosub [h2Dot]
r    = 30 ' radius
p    = hr * 5
#g2 color("white")
gosub [h2Dot]
 
'
' Show new time
'
a$    = time$()
hr    = val(word$(a$,1,":"))
mi    = val(word$(a$,2,":"))
se    = val(word$(a$,3,":"))
 
' put time on the clock - gimme a hand
#g2 size(4)
' second hand
n    = 60
r    = 63
p    = se
#g2 color("blue")
gosub [h2Dot]
 
' minute hand
r    = 50
p    = mi
#g2 color("green")
gosub [h2Dot]
 
' hour hand
r    = 30 ' radius
p    = hr * 5
#g2 color("red")
gosub [h2Dot]
 
' place graphic and digital time web page
html "<script> document.getElementById('";pid$;"').innerHTML = '"
render #g2
html "<BR>";a$
html "';</script>"
RETURN
 
' a one liner
[h2Dot]
alpha    = pi * 2 / n
i     = p - 15
theta     = alpha * i
px     = cos( theta ) * r
py     = sin( theta ) * r
px     = px + 100
py     = py + 100
#g2 place(px,py)
#g2 circle(2)
#g2 line(100,100,px,py)
RETURN