Microsoft Small Basic

Program Listing: TJK786
counter = 0
flg = 0

GraphicsWindow.Title = "Count..."
GraphicsWindow.Width = 200
GraphicsWindow.Height = 30
GraphicsWindow.CanResize = 0
GraphicsWindow.BackgroundColor = "#EEEEEE"
GraphicsWindow.FontSize = 18
GraphicsWindow.BrushColor = "#000000"
GraphicsWindow.DrawText(0,0,counter)
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.Show()

Timer.Interval = 1000
Timer.Tick = OnTick

Sub OnKeyDown
key = GraphicsWindow.LastKey
If (key = "Return") Then
If (flg = 0) Then
Timer.Pause()
GraphicsWindow.Title = "Stop"
Else
GraphicsWindow.Title = "Count..."
Timer.Resume()
EndIf
flg = Math.Remainder((flg + 1) ,2)
EndIf
EndSub

Sub OnTick
GraphicsWindow.Clear()
counter = counter + 1
GraphicsWindow.DrawText(0,0,counter)
EndSub