Here is a simple stopwatch with lap times. Note that the machine switches off automatically after a time if no keys are pressed; you may want to disable this feature via the Control Panel on the System screen before running this program.
Each timing is only accurate to within one second, as the procedure is based on the SECOND function.
PROC watch: LOCAL k%,s%,se%,mi% FONT 11,16 AT 20,1 :PRINT "Stopwatch" AT 15,11 :PRINT "Press a key to start" GET DO CLS :mi%=0 :se%=0 :s%=SECOND AT 15,11 :PRINT " S=Stop, L=Lap " loop:: k%=KEY AND $ffdf REM ensures upper case IF k%=%S GOTO pause:: ENDIF IF k%=%L AT 20,6 :PRINT "Lap: ";mi%;":"; IF se%<10 :PRINT "0"; :ENDIF PRINT se%;" "; ENDIF IF SECOND<>s% s%=SECOND :se%=se%+1 IF se%=60 :se%=0 :mi%=mi%+1 :ENDIF AT 17,8 PRINT "Mins",mi%,"Secs", IF se%<10 :PRINT "0"; :ENDIF PRINT se%;" "; ENDIF GOTO loop:: pause:: mINIT mCARD "Watch","Restart",%r,"Zero",%z,"Exit",%x k%=MENU IF k%=%r GOTO loop:: ENDIF UNTIL k%<>%z ENDP