[comp.sys.ibm.pc] Simple, stupid PD program wanted

doug@homxc.UUCP (D.SULPY) (08/03/88)

Can someone post or email me a simple program that will allow me to
use the built-in clock in my computer as a stopwatch? What I want
to be able to do is to run the program, hit any key to begin timing,
and hit any key to stop timing. Sounds simple enough, but I can't
figure out how to do it. I've tried the Norton TM utility, but the
fact that it accesses the disk everytime it's run destroys the
accuracy. I've tried writing a simple BASIC program using the
TIMER function, but - again - I've failed. Not being able to do
what is evidently a very simple thing is driving me CRAZY! Thanks!

brown@nicmad.UUCP (Mr. Video) (08/05/88)

In article <2911@homxc.UUCP> doug@homxc.UUCP (D.SULPY) writes:
<Can someone post or email me a simple program that will allow me to
<use the built-in clock in my computer as a stopwatch? What I want
<to be able to do is to run the program, hit any key to begin timing,
<and hit any key to stop timing. Sounds simple enough, but I can't
<figure out how to do it. I've tried the Norton TM utility, but the
<fact that it accesses the disk everytime it's run destroys the
<accuracy. I've tried writing a simple BASIC program using the
<TIMER function, but - again - I've failed. Not being able to do
<what is evidently a very simple thing is driving me CRAZY! Thanks!

The following is untested, but give it a try (QuickBASIC):

cls
print "Press any key to start, then any key to stop."
while inkey$=""
wend
start!=timer
while inkey$=""
   currenttime!=timer-start!
   currenthr%=currenttime!\3600%
   currentmn%=(currenttime!-(currenthr%*3600%))\60%
   currentsc%=(currenttime!-(currenthr%*3600%)-(currentmn%*60%))
   currentd%=((currenttime!-(currenthr%*3600%)-(currentmn%*60%)-currentsc%)*100)
   currentsec!=currentsc%+(currentd%/100)
   locate 10,40
   print currenthr%+":"+currentmn%+":"+currentsec!;
wend
end

The net result should be a time with hours:minutes:seconds.hundreds
The format is terrible here, but this should give you idea.  A print using
statement can be used to give hh:mm:ss.dd format real easy.  I realise that
the resolution will be poor, especially if the program isn't compiled.

You can make the program only do the printing to the screen after the second
pressing of any key.  That will improve the timing resolution.

I hope this helps, but again remember, it is untested.
-- 
	       harvard-\	att!terminus--\
Mr. Video         ucbvax!uwvax.................!nicmad!brown
	       rutgers-/        att-/ decvax--/