Microsoft Small Basic

Program Listing: DNS916
GraphicsWindow.Title = "Count Down Timer - Hit any key to restart."
Init()
start = Clock.ElapsedMilliseconds
While "True"
' count down timer loop
While 0 <= time
now = Clock.ElapsedMilliseconds
time = Math.Floor(interval - (now - start))
If 0 <= time Then
time = Text.Append(Text.GetSubTextToEnd("000", Text.GetLength(time)), time)
Shapes.SetText(txt, time)
EndIf
EndWhile
' wait key input to restart the timer
keyDown = "False"
While Not[keyDown]
Program.Delay(300)
EndWhile
start = Clock.ElapsedMilliseconds
time = interval
EndWhile
Sub Init
Not = "True=False;False=True;"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.FontName = "Trebuchet MS"
GraphicsWindow.FontSize = 200
GraphicsWindow.BrushColor = "Black"
txt = Shapes.AddText("")
Shapes.Move(txt, 64, 100)
interval = 5000
time = interval
GraphicsWindow.KeyDown = OnKeyDown
EndSub
Sub OnKeyDown
keyDown = "True"
EndSub