Calculator Community > TI-BASIC
Help with startTmr and checkTmr
(1/1)
Tape:
I am trying to make a program that detects how many times the user has pressed enter until the timer goes up
(it's not going as planned)
here goes
--- Code: ---10->V
startTmr->
0->B
checkTmr(A)->X
Lbl 88
If V>=X>=0
Then
0->T
Lbl87
getKey->T
If T=105
Then
B+1->B
If checkTmr(A)>V
Then
goto 88
End
ClrHome
End
If T =/= 105
Then
Goto 87
End
Lbl 89
Disp "Coins Earned:",B
--- End code ---
Geekboy1011:
I made some edits to the post for you to move the code into a code block, you can do that with code tags [code] *code here* [/code]The edit button can show you what I mean!
I will take a look at the code some more later but nice to have you on the forum! Maybe someone will get to this before me tho :) We talked on IRC earlier about you possible using IF Then blocks wrong. Have you looked into this yet?
Xeda112358:
There are a lot of issues with the code. An example is that If ... Then need and End
Here is how I would code it:
--- Code: ---0→C ;This is our counter
startTmr→T
While checkTmr(T)<10
If getKey=105
C+1→C ;Since our IF block is only 1 line of code, we don't need a Then... End
End ;for the While loop
Disp "PRESSED ENTER",C,"TIMES"
--- End code ---
Since the If statement only had one line of code, it doesn't need a Then... End
The optimized version looks like:
--- Code: ---startTmr→T
0
While 10>checkTmr(T
Ans+(getKey=105 ;In BASIC a TRUE statement returns 1, a FALSE statement returns 0. So this adds 1 to Ans when getKey=105
End
Disp "PRESSED ENTER",Ans,"TIMES"
--- End code ---
EDIT: Fixed a copy-paste typo, added some comments, fixed title
Navigation
[0] Message Index
Go to full version