# Timer in Pascal

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

• : 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
:
:
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]
• : 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
:
: