Many experiments will revolve around gathering timing information, typically how long it takes a subject to respond to particular stimuli; Experimentor makes this very easy.

Similar to rectangles, circles, text, images, a timer object must be created before it can be used. However, unlike other types of objects you do not need to first define a type of timer; instead it can simply be created because the Timer type is always pre-defined for you.  For example the following defines a new timer object and stores it in the stimuliTimer variable:

define stimuliTimer  = create Timer

Timer actions

There are two basic actions that can be performed with a timer:  starting it and stopping it.

Starting a timer

To start a timer simply use the start keyword and then the name of your timer:

start stimuliTimer

Note: Starting a stopped timer resets the timer back to zero.

Stopping a timer

Similarly, to stop a timer you simply use the stop keyword followed by the name of the timer you wish to stop:

stop stimuliTimer

Stopping a timer also returns the final duration of the timer in milliseconds, so you can do either of the following to determine how long your timer was started:

define durationInMs = stop stimuliTimer

or if you have previously defined the “durationInMs” variable, you would simply use:

durationInMs = stop stimuliTimer

Elapsed timer duration

You can also find out the duration of the timer by using the “milliseconds” timer variable:

define durationInMs = stimuliTimer.milliseconds

This allows you to determine the elapsed time without stopping the timer, or after the time has been stopped.

Timer example

The following example demonstrates how to display a circle on the screen and then print how long it takes the subject to click on that circle:

define type of circle stimuliType

       radius = 40%

       x = 50%

       y = 50%

       colour = #FF00FF

end circle

define stimuli = create stimuliType

define stimuliTimer = create Timer

define trial timedClickTrial

       define phase showCirclePhase

               // Show the circle and wait 20 seconds for the subject to click on it.

               // Time how long it took the subject to click on the circle

               // When they click on the circle stop the timer, print how long it took and then end the phase

               when stimuli.ClickCount changes

                       stop stimuliTimer

                       print(“It took the subject ” + stimuliTimer.milliseconds + “ms to click on the circle”)

                       goto phase endPhase

               end when

               // Show the stimuli circle and then immediately start the timer

               stimuli.IsVisible = true

               start stimuliTimer

               // Give the users only 20 seconds to actually click on the timer


               stop stimuliTimer

               goto phase endPhase

       end phase

       define phase endPhase

               // Empty phase

       end phase

end trial

wait for 2sec                        // Give the subject time to get ready

run timedClickTrial