How accurate do you want this countdown?
Seconds
 25%  [ 2 ]
Milliseconds
 50%  [ 4 ]
Less then milliseconds
 25%  [ 2 ]
Total Votes : 8

I have been working on a stopwatch/countdown program, and I am having problems with the code.
Here's the problem:

Code:
M→Z
20→A
While Z≠0
A+1→A
A-1→A
A+1→A
A-2→A
A+1→A
A-1→A
If S=0:Then:M-1→M:Z-1→Z:60→S:End
If A=0:Then:Then:S-1→S:20→A:End
End:Disp "TIME UP!"

I do have it output( it in the code, but when it has a minute left, it displays "TIME UP!". I want it to display it when everything equals 0.
What you want is startTimer aka. startTmr
That gives you accurate seconds!

The easy and modular countdown way (Uses A for total secs, Uses D for secs left; Destroys B and C; Put your code instead of the Disp D):

Code:
Input "Secs: ",A
startTmr->B
checkTmr(B)->C
While C<A
A-C->D
Disp D
While A-C=D
checkTmr(B)->C
End
End
Disp "TIME OUT!"


The heavily optimized countdown oneliner (supply total secs in A; Destroys Ans and B):

Code:
1:startTmr->B:While Ans:A-checkTmr(B:Disp Ans:End


The easy and modular stopwatch way (Uses B for elapsed secs; Destroys A), press any key to stop the stopwatch:

Code:
startTmr->A
Repeat getKey
checkTmr(A)->B
Disp B
End
Disp "BREAK!"
Also, if you want a counting up timer, this is a good way to do it. It is easily modifiable to go down as well. Smile


Code:
0->B
Repeat Ans
Disp B
B+1->B
startTmr->A:0
Repeat Ans+checkTmr(A
getKey
End
End


Countdown:

Code:
10->B  ; Number of Seconds
While B
startTmr->A
Repeat checkTmr(A:End
B-1->B
Disp B
End
Thank you for the count-up timer. While I do have that part, I just needed something for a countdown timer. Thanks!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement