Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Timer in Pascal

swe_kitsuneswe_kitsune Posts: 1Member
Hello everyone!

I'm quite new to pascal, but I still know quite alot. Anyway, I am trying to create a reactiontester. The screen flashes and then you have to press a button, and the compouter calculates the time it took for you to press the button. And I have no idea what I should write to make this happen. I tried using a repeat until keypress, something like:

a:=0;
repeat;
a:=a+1
delay(1)
until keypressed;

I put the delay there just so I know how long it takes before every repeat, but still, this doesn't work any well... So if anyone know how to use a real time, please respond!

Marcus Olsson
-(Sorry about my bad english)

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hello everyone!
    :
    : I'm quite new to pascal, but I still know quite alot. Anyway, I am trying to create a reactiontester. The screen flashes and then you have to press a button, and the compouter calculates the time it took for you to press the button. And I have no idea what I should write to make this happen. I tried using a repeat until keypress, something like:
    :
    : a:=0;
    : repeat;
    : a:=a+1
    : delay(1)
    : until keypressed;
    :
    : I put the delay there just so I know how long it takes before every repeat, but still, this doesn't work any well... So if anyone know how to use a real time, please respond!
    :
    : Marcus Olsson
    : -(Sorry about my bad english)
    :
    :
    Here is the pseudocode of how to do that:
    [code]
    - flash screen
    - Get First Current Time
    - repeat until Keypressed
    - Get Second Current Time
    - Calculate time difference between 1 & 2
    [/code]
  • Phat NatPhat Nat Posts: 757Member
    : Hello everyone!
    :
    : I'm quite new to pascal, but I still know quite alot. Anyway, I am trying to create a reactiontester. The screen flashes and then you have to press a button, and the compouter calculates the time it took for you to press the button. And I have no idea what I should write to make this happen. I tried using a repeat until keypress, something like:
    :
    : a:=0;
    : repeat;
    : a:=a+1
    : delay(1)
    : until keypressed;
    :
    : I put the delay there just so I know how long it takes before every repeat, but still, this doesn't work any well... So if anyone know how to use a real time, please respond!
    :
    : Marcus Olsson
    : -(Sorry about my bad english)
    :
    :

    Check out this thread. Alot of people had responses:
    http://www.programmersheaven.com/c/msgboard/read.asp?Board=16&MsgID=301369&Setting=A9999F0004

    Phat Nat
Sign In or Register to comment.