Here you go, this uses a self syncronising timer based on millisecs, and one which I use for all timing.
sw=ClientWidth(Desktop()) sh=ClientHeight(Desktop()) app=CreateWindow("Counter",(sw/2)-70,(sh/2)-40,126,80,0,1) quit=False panel=CreatePanel(0,0,130,80,app):SetPanelColor panel,128,160,192:SetGadgetLayout panel,1,0,1,0 start=CreateButton("start",4,4,40,24,panel) disconnect=CreateButton("stop",48,4,40,24,panel) minimize=CreateButton("_",96,6,20,20,panel) timerfile$="c:\My Documents\CS_TBL_counter.dat" f=ReadFile(timerfile$) If Not f f=WriteFile (timerfile$) WriteLine f,0 CloseFile f f=ReadFile(timerfile$) Else seconds=ReadLine$(f) CloseFile f EndIf DisableGadget disconnect Seconds=0 startlabel=CreateLabel(seconds+" ( "+secs2time(seconds)+" )",4,32,112,20,panel,3) Global LastTime Repeat WaitEvent() If EventID()=$803 If EventSource()=app f=WriteFile(timerfile$) WriteLine f,seconds CloseFile f quit=True EndIf EndIf If EventID()=$401 If EventSource()=start timer=CreateTimer(5) LastTime=MilliSecs() DisableGadget start EnableGadget disconnect EndIf If EventSource()=disconnect If timer FreeTimer timer f=WriteFile(timerfile$) WriteLine f,seconds CloseFile f DisableGadget disconnect EnableGadget start EndIf If EventSource()=minimize MinimizeWindow app EndIf EndIf If EventID()=$4001 If EventSource()=timer Seconds=UpdateSeconds(Seconds) SetGadgetText startlabel,seconds+" ( "+secs2time(seconds)+" )" EndIf EndIf Until quit End Function UpdateSeconds(Secs) ThisTime=MilliSecs()-LastTime If ThisTime=>1000 Repeat Secs=Secs+1 ThisTime=ThisTime-1000 Until ThisTime<1000 LastTime=MilliSecs()-ThisTime EndIf Return Secs End Function Function secs2time$(s) hours= s / 3600 mins = (s / 60) Mod 60 secs = s Mod 60 Return addzero(hours,3)+":"+addzero(mins,2)+":"+addzero(secs,2) End Function Function addzero$(s$,l) s$=RSet$(s$,l) s$=Replace$(s$," ","0") Return s$ End Function