Timer in Pascal - Programmers Heaven

Howdy, Stranger!

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

Categories

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.