# Timer

Discussion in 'Computer Science & Culture' started by Spectrum, Jan 28, 2011.

Not open for further replies.
1. ### SpectrumRegistered Senior Member

Messages:
459
The following is a timer written in qbasic (Windows 98/tools/oldmsdos). It continues to performs a counting operation while it remains the same second as when it began the process. The results are then printed to the screen as a percentage and then raw data (but you can use a file (or both)). However the largest number it should be able to achieve here is 255 (8 bits) and for that to be (almost) true then each c% should be printed to the screen. As the code stands the percentages are (usually) higher than one hundred.

Code:
'TimeReset
2 a%=val(mid$(time$,8,1))
b%=val(mid$(time$,8,1))
while b%=a%
b%=val(mid$(time$,8,1))
wend
'TimeSet
a%=val(mid$(time$,8,1))
b%=val(mid$(time$,8,1))
while b%=a%
b%=val(mid$(time$,8,1))
c%=c%+1
wend
p%=(c%/256)*100
print date$;" ";time$;" ";p%;"% ";c%
goto 2

Now all I need to do is write a code that allows this to run in the baground while other programs are running...

3. ### ChipzBannedBanned

Messages:
838
I am going to show you a nifty little trick.

Code:
'TimeReset
2
a%=val(mid$(time$,8,1))
b%=val(mid$(time$,8,1))

while b%=a%
b%=val(mid$(time$,8,1))
wend

'TimeSet
a%=val(mid$(time$,8,1))
b%=val(mid$(time$,8,1))

while b%=a%
b%=val(mid$(time$,8,1))
c%=c%+1
wend

p%=(c%/256)*100

print date$;" ";time$;" ";p%;"% ";c%

goto 2
WOW! LOOK AT THAT!! YOU CAN READ IT!!!

But seriously, I wave to ask. Why on earth are you using Qbasic? It's one of the most antiquated and worthless languages barely in existence.

5. ### SpectrumRegistered Senior Member

Messages:
459
Well it's good enough to produce random numbers and it seems to have everything I need.

Oh yeah, I missed c%=0 before the incrementation loop.

7. ### txrexRegistered Member

Messages:
25
Thanks chipz, I was thinking of doing that as I was reading.... then I scrolled down

8. ### ChipzBannedBanned

Messages:
838
You will never be hired as a programmer.

9. ### Giambattistasssssssssssssssssssssssss sssssValued Senior Member

Messages:
4,878
I got no clue what yall is talking bout, but if I had money, I'd hire that person in a heartbeat!

A charitable heartbeat.