Page 1 of 1

Measuring response time

Posted: Wed Oct 02, 2013 8:10 pm
by jamesmoroni
Hello,

I"m trying to build an app that will measure a user's response time by measuring how long after a button is clicked for it to become visible. The simplest solution is to have one button put the milliseconds * -1 into a field then hide the response button and show it after a random interval. Once the response button is clicked it adds the miliseconds to the field and the time difference between the button appearing and the mousedown are recorded in the field.

The challenge arises when I try to record subsequent scores on each line of the field All my attempts to count down the lines with a variable and put the new score on the next line result in errors. I've tried local and global variables, intermediate steps, and a ton of different approaches.

Here's my current card script:

Code: Select all

global whichline
global responsetime
global showtime
global clearline

on startgame
   hide button 1
   put 0 into whichline
   nextturn
end startgame

on nextturn
   put random(1000)+500 into waittime
   add 1 to whichline
   hide button 1
   wait waittime milliseconds
   show button 1
   put the milliseconds into showtime
end nextturn
and the response button script:

Code: Select all

on mouseDown
   put the milliseconds - showtime into line whichline of field 1
   nextturn
end mouseDown


The stack consists of just the button and the field, and a couple of other buttons to start the game and clear the field. I'll see if I can attach it.


Anyways thanks for the help. I'm sure there's some stupd mistake i'm making but I can't figure out what it is. The recording line works in the message box but not from the button for some reason.

Re: Measuring response time

Posted: Wed Oct 02, 2013 8:56 pm
by Klaus
Hi James,

you need to declare a GLOBAL in every script you use it!

This should do the trick:

Code: Select all

on mouseDown
   global showtime
   put the milliseconds - showtime into line whichline of field 1
   nextturn
end mouseDown
Best

Klaus

Re: Measuring response time

Posted: Thu Oct 03, 2013 3:59 pm
by jamesmoroni
Klaus wrote:Hi James,

you need to declare a GLOBAL in every script you use it!

This should do the trick:

Code: Select all

on mouseDown
   global showtime
   put the milliseconds - showtime into line whichline of field 1
   nextturn
end mouseDown
Best

Klaus

Klaus,

Thanks so much. Works great now.

James