Measuring response time

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jamesmoroni
Posts: 2
Joined: Wed Oct 02, 2013 7:38 pm

Measuring response time

Post by jamesmoroni » Wed Oct 02, 2013 8:10 pm

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.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Measuring response time

Post by Klaus » Wed Oct 02, 2013 8:56 pm

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

jamesmoroni
Posts: 2
Joined: Wed Oct 02, 2013 7:38 pm

Re: Measuring response time

Post by jamesmoroni » Thu Oct 03, 2013 3:59 pm

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

Post Reply