Author Topic: Help with startTmr and checkTmr  (Read 4564 times)

0 Members and 1 Guest are viewing this topic.

Offline Tape

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 5
  • Rating: +0/-0
    • View Profile
Help with startTmr and checkTmr
« on: April 08, 2019, 03:42:01 pm »
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: [Select]
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
« Last Edit: April 08, 2019, 04:30:46 pm by Eeems »

Offline Geekboy1011

  • The Oneironaut
  • Donator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2031
  • Rating: +119/-2
  • Dream that Awakening dream
    • View Profile
Re: help
« Reply #1 on: April 08, 2019, 04:07:44 pm »
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?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Help with startTmr and checkTmr
« Reply #2 on: April 08, 2019, 04:21:14 pm »
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: [Select]
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"
Since the If statement only had one line of code, it doesn't need a Then... End


The optimized version looks like:
Code: [Select]
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"
EDIT: Fixed a copy-paste typo, added some comments, fixed title