Displaying a countdown timer for participants

2,445 views
Skip to first unread message

Joseph Williams

unread,
Mar 17, 2008, 9:34:21 PM3/17/08
to e-p...@googlegroups.com
Hi, I'd like to be able to display how much time participants have left to make a response- e.g. a textobject on a slide that appears when there are 10 seconds left, and counts down from 10 to 0. Does anyone have any ideas on how to implement this?

Thanks,

Joseph

ben robinson

unread,
Mar 18, 2008, 9:51:49 AM3/18/08
to e-p...@googlegroups.com
you could try setting your slide's duration to zero (with a response window of however many seconds you need).
then in an inline immediately after the slide is presented...
Do
   Select Case SlideX.TimeLimit - (Clock.Read - SlideX.OnsetTime)
      Case 9995 to 10005
         c.SetAttribAtSource "Remaining", 10
      Case 8885 to 9005
         c.SetAttribAtSource "Remaining", 9
      Case...
      Case 995 to 1005
         c.SetAttribAtSource "Remaining", 1
   End Select
Loop While Clock.Read - SlideX.OnsetTime < SlideX.TimeLimit

this is just a guess.  let me know if it works.

ben

Joseph Williams

unread,
Apr 9, 2008, 11:39:54 PM4/9/08
to e-p...@googlegroups.com
Hi Ben,

Thanks for the advice. I'm going to try to implement this soon, so I'll let you know how it works out.

Joseph

Matt Lenhart

unread,
Apr 16, 2008, 1:37:44 PM4/16/08
to E-Prime
Hello,

Ben's advice is very good and is the method we would recommend. I have
added our formal sample (CountDownClock.es) to the Files section of
this group for reference. If you have any questions, please let me
know.

Sincerely,
Matt Lenhart
PST Technical Consultant
http://pstnet.com

CarlF

unread,
Apr 25, 2008, 4:53:29 PM4/25/08
to E-Prime
Hi Matt -

Thanks for making the very helpful example available for download.

I do have a further question.

If the countdown timer in CountDownClock.es were not text, but
rather were a series of images to be presented through the services
of a SlideImage object, can I do a Load before the Draw inside the
countdown loop, without the Load of the next image glitching the
display of the image that was Draw(n) in the previous iteration
of the loop?

Suppose I put a first Load outside the loop, and then have the in-loop
order of operations be to Draw, and then to Load the next image.
Does this give me fairly fine grained control of when images
are displayed? Is there any time auditing info that will reliably
tell
me when the most recent Draw of any SlideStim child object occurred,
so that I can track time stolen by the o/s?

Lastly, assuming that Draw and Load are atomic in the way that
I'm hoping: Suppose that I'm drawing a succession of large images
to a screen region--for purposes of discussion, let's say its a
pre-animated full-screen countdown timer running at 30 frames
a second--that may not reliably roll off of disk fast enough. Is
there a way I can buffer these images outside the countdown
loop, and then Load them from the in-memory buffer to the
SlideImage object, so that they are available well before I get
back around to the Draw operation?

Thanks so much for your help.

Cheers,

Carl F.

yaku...@gmail.com

unread,
Aug 19, 2014, 8:26:38 PM8/19/14
to e-p...@googlegroups.com
Hello Matt,

I'm sorry if it's a dumb question, but where can I download the sample CountDownClock.es?
I'm new to this group and I couldn't find files section. And I'm in desperate need of the countdown timer :)

Thank you!
Natalia

sunnygu

unread,
Aug 19, 2014, 9:22:57 PM8/19/14
to e-p...@googlegroups.com
Dear Natalia,
As far as I know, I think there is no file download section and you can try in PST community since this is a discussion forum. And I may suppose you can try gettimer  function in eprime or search timer in help for ebasic to see if there is any function you can use. 
My best,

Sally

发自我的 iPhone
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/7ec6329b-240c-41ef-8f7f-0fa87cda04e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David McFarlane

unread,
Aug 21, 2014, 4:05:47 PM8/21/14
to e-p...@googlegroups.com
Natalia,
Indeed, Matt Lenhart from PST posted that file to
the Group over 6 years ago, back when Google
Groups included a files section. Google Groups
has since discontinued that feature. But you may
still download that example directly from the PST
website. You will need to register and login
there first in order to get to the Sample Programs area.

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (https://twitter.com/EPrimeMaster)

/----
Stock reminder: 1) I do not work for PST. 2)
You may reach PST's trained staff (and other
support facilities) at https://support.pstnet.com
. 3) If you do get an answer from PST staff,
please extend the courtesy of posting their reply
back here for the sake of others.
\----


At 8/19/2014 09:22 PM Tuesday, sunnygu wrote:
>Dear Natalia,
>As far as I know, I think there is no file
>download section and you can try in PST
>community since this is a discussion forum. And
>I may suppose you can try gettimer function in
>eprime or search timer in help for ebasic to see
>if there is any function you can use.
>My best,
>
>Sally
>
>å ‘è‡ªæˆ‘çš„ iPhone
>
>在
>2014å¹´8月20æ—¥ï¼Œä¸Šå ˆ8:26,<mailto:yaku...@gmail.com>yaku...@gmail.com
>å†™é “ï¼š
>
>>Hello Matt,
>>
>>I'm sorry if it's a dumb question, but where
>>can I download the sample <http://CountDownClock.es>CountDownClock.es?
>>I'm new to this group and I couldn't find files
>>section. And I'm in desperate need of the countdown timer :)
>>
>>Thank you!
>>Natalia
>>
>>On Thursday, April 17, 2008 2:37:44 AM UTC+9, Matt wrote:
>>Hello,
>>
>>Ben's advice is very good and is the method we would recommend. I have
>>added our formal sample
>>(<http://CountDownClock.es>CountDownClock.es) to the Files section of
>>this group for reference. If you have any questions, please let me
>>know.
>>
>>Sincerely,
>>Matt Lenhart
>>PST Technical Consultant
>><http://pstnet.com>http://pstnet.com

Cognitology

unread,
Aug 27, 2014, 11:56:52 AM8/27/14
to e-p...@googlegroups.com
Hi,
I'm not sure whether this would serve as a countdowntimer in the absence of the Real Deal, but here's a quick and dirty way of drawing a progressbar (the reverse of a countdown, easily fixed).

1. Have a textDisplay, we call it TextDisplay1, duration 1, timelimit 10000 (or end of procedure, that also works). Add keyboard.
2. Add inline after this textDisplay:

'---------
Dim cnvs As canvas
Dim percdone As Integer
Set cnvs = Display.Canvas
cnvs.PenColor = CColor("black")
cnvs.FillColor = CColor("white")

cnvs.Rectangle Display.Xres / 2-100,Display.Yres / 2-10, 200, 20 'draw bar
cnvs.FillColor = CColor("red")
Do 'specially for David McFarlane, I'd use WHILE sneakily
percdone = (clock.read - textdisplay2.OnsetTime) / 100
cnvs.Rectangle Display.Xres / 2-100,Display.Yres / 2-10, 2*percdone, 20 'draw filler
sleep 10
Loop Until ((clock.read - textdisplay1.OnsetTime) > 10000) Or TextDisplay2.RESP <> "" 'because loop until sounds silly.
'----------

It works in EP2, probably in 1 as well. It shows a bar for 10 s, overlaying with whatever is on the screen (make textdisplay1 transparent for more options), and shows until end of response or end of 10s.


It's not fantastic, I just wrote this in a few minutes. I'm not sure, for instance, if sleep 10 is necessary, for instance - if memory serves, EP2 always adds a display.waitforverticleblank after canvas operations.
Best,
Michiel

Michiel Sovijärvi-Spapé
Helsinki Institute for Information Technology HIIT
Aalto & Helsinki University
Finland
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/53f65118.61e1320a.6681.24f8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.

Cognitology

unread,
Aug 29, 2014, 7:54:22 AM8/29/14
to e-p...@googlegroups.com
Hi,
Oops, correction:

1. Have a textDisplay, we call it PreText, duration 1, timelimit 10000 (or end of procedure, that also works). Add keyboard.
2. Add inline after this PreText:

'---------
Dim cnvs As canvas
Dim percdone As Integer
Set cnvs = Display.Canvas
cnvs.PenColor = CColor("black")
cnvs.FillColor = CColor("white")

cnvs.Rectangle Display.Xres / 2-100,Display.Yres / 2-10, 200, 20 'draw bar cnvs.FillColor = CColor("red") Do 'specially for David McFarlane, I'd use WHILE sneakily
percdone = (clock.read - PreText.OnsetTime) / 100
cnvs.Rectangle Display.Xres / 2-100,Display.Yres / 2-10, 2*percdone, 20 'draw filler
sleep 10
Loop Until ((clock.read - PreText.OnsetTime) > 10000) Or PreText.RESP <> "" 'because loop until sounds silly.
'----------

It works in EP2, probably in 1 as well. It shows a bar for 10 s, overlaying with whatever is on the screen (make PreText transparent for more options), and shows until end of response or end of 10s.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/03f101cfc20f%247fdaafd0%247f900f70%24%40eu.

35castro...@cua.edu

unread,
Dec 14, 2017, 5:59:56 PM12/14/17
to E-Prime
Hi I tried this, but I get an error about the PreText and I only get a rectangle>?

David McFarlane

unread,
Dec 15, 2017, 10:07:04 AM12/15/17
to e-p...@googlegroups.com
The post that you reference may go back to before E-Prime 2.0.10, and
since then an important change happened that may affect the running of
this code. Please see thread at
groups.google.com/d/topic/e-prime/kWQWvT6AMvo and then follow the links
posted there.

-- David McFarlane
>> Twitter: @EPrimeMaster (https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_EPrimeMaster&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=j0-KCHLNIi66qRIy-6FjSPFbsJCjvZcHQLcWkiIWnRo&e=)
>>
>> /----
>> Stock reminder: 1) I do not work for PST. 2)
>> You may reach PST's trained staff (and other
>> support facilities) at https://urldefense.proofpoint.com/v2/url?u=https-3A__support.pstnet.com&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=3ZhdiW9dgxSon6fSGYc2ghtA2F7P0AxbL5lDcqncMik&e=
>> . 3) If you do get an answer from PST staff,
>> please extend the courtesy of posting their reply
>> back here for the sake of others.
>> \----
>>
>>
>> At 8/19/2014 09:22 PM Tuesday, sunnygu wrote:
>>> Dear Natalia,
>>> As far as I know, I think there is no file
>>> download section and you can try in PST
>>> community since this is a discussion forum. And
>>> I may suppose you can try gettimer function in
>>> eprime or search timer in help for ebasic to see
>>> if there is any function you can use.
>>> My best,
>>>
>>> Sally
>>>
>>> å ‘è‡ªæˆ‘çš„ iPhone
>>>
>>> 在
>>> 2014å¹´8月20æ—¥ï¼Œä¸Šå ˆ8:26,<mailto:yaku...@gmail.com <javascript:>>
>> yaku...@gmail.com <javascript:>
>>> å†™é “ï¼š
>>>
>>>> Hello Matt,
>>>>
>>>> I'm sorry if it's a dumb question, but where
>>>> can I download the sample <https://urldefense.proofpoint.com/v2/url?u=http-3A__CountDownClock.es&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=qgs3VVSfObZ-UPVDjhWgJ-hRd89rl1FTJ4kIKYLdXJs&e=>CountDownClock.es?
>>>> I'm new to this group and I couldn't find files
>>>> section. And I'm in desperate need of the countdown timer :)
>>>>
>>>> Thank you!
>>>> Natalia
>>>>
>>>> On Thursday, April 17, 2008 2:37:44 AM UTC+9, Matt wrote:
>>>> Hello,
>>>>
>>>> Ben's advice is very good and is the method we would recommend. I have
>>>> added our formal sample
>>>> (<https://urldefense.proofpoint.com/v2/url?u=http-3A__CountDownClock.es&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=qgs3VVSfObZ-UPVDjhWgJ-hRd89rl1FTJ4kIKYLdXJs&e=>CountDownClock.es) to the Files section of
>>>> this group for reference. If you have any questions, please let me
>>>> know.
>>>>
>>>> Sincerely,
>>>> Matt Lenhart
>>>> PST Technical Consultant
>>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__pstnet.com&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=Ru7JeC67mXfkTvtekKeJQgvDLL9a2ayCH8P-Q-7uMQk&e=>https://urldefense.proofpoint.com/v2/url?u=http-3A__pstnet.com&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=Ru7JeC67mXfkTvtekKeJQgvDLL9a2ayCH8P-Q-7uMQk&e=
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "E-Prime" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to e-prime+u...@googlegroups.com <javascript:>.
>> To post to this group, send email to e-p...@googlegroups.com <javascript:>.
>>
>> To view this discussion on the web visit
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_e-2Dprime_53f65118.61e1320a.6681.24f8SMTPIN-5FADDED-5FMISSING-2540gmr-2Dmx.google.com&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=7TCy_zcW_WwsQr3KTOVvE75BrYAVgcB7b7lZx6tJQk8&e=.
>>
>> For more options, visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_optout&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=UBxegMiDHCdPVvxuop11uOHaEt29UZf0V8kha6WSkiE&e=.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "E-Prime" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to e-prime+u...@googlegroups.com <javascript:>.
>> To post to this group, send email to e-p...@googlegroups.com <javascript:>.
>>
>> To view this discussion on the web visit
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_e-2Dprime_03f101cfc20f-25247fdaafd0-25247f900f70-2524-2540eu&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=Au8vvh09tL7xxbAd0fH6F4te19jvgei8VTXZ6YBCpno&e=.
>>
>> For more options, visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_optout&d=DwIFaQ&c=nE__W8dFE-shTxStwXtp0A&r=rVCe0bDlnqQHHAg2cizkHg&m=CO0Nsv2Ty4My2hRSnjXaDDYhCqrQaxUZWzVTkME-i2s&s=UBxegMiDHCdPVvxuop11uOHaEt29UZf0V8kha6WSkiE&e=.

Richard Kirkden

unread,
Mar 8, 2018, 6:50:47 AM3/8/18
to E-Prime
The code provided by Cognitology worked beautifully! The progress bar looks great and is easy to resize, and also quite easy to modify for different durations. I think it will be a very good way to give participants a feeling of time pressure.

Also, it was very easy to modify the progress bar code so that it counts down across a whole block of trials, instead of resetting on each trial. (I used clock.read to save the onset time of the block to a variable called blockOnsetTime and substituted this for PreText.OnsetTime.) This was particularly useful. There are other ways to implement a countdown on a single slide (e.g. adding a movie of a countdown timer to the slide), but I've never before come across a way to create a countdown display that continues across successive slides.

So thank you for a really useful bit of code!


Michiel Spape

unread,
Mar 8, 2018, 9:25:49 AM3/8/18
to e-p...@googlegroups.com

Hi,

Thanks! I had to look up what you were replying to – something I wrote about 4 years ago J

Anyway, happy that this helped someone. More tips can be found in our book, The E-Primer (which was probably published around the time I wrote the email…)

Best,

Michiel Spape

 

Lecturer in Psychology

Liverpool Hope University

 

From: e-p...@googlegroups.com [mailto:e-p...@googlegroups.com] On Behalf Of Richard Kirkden
Sent: 08 March 2018 11:51
To: E-Prime <e-p...@googlegroups.com>
Subject: Re: Displaying a countdown timer for participants

 

The code provided by Cognitology worked beautifully! The progress bar looks great and is easy to resize, and also quite easy to modify for different durations. I think it will be a very good way to give participants a feeling of time pressure.

 

Also, it was very easy to modify the progress bar code so that it counts down across a whole block of trials, instead of resetting on each trial. (I used clock.read to save the onset time of the block to a variable called blockOnsetTime and substituted this for PreText.OnsetTime.) This was particularly useful. There are other ways to implement a countdown on a single slide (e.g. adding a movie of a countdown timer to the slide), but I've never before come across a way to create a countdown display that continues across successive slides.

 

So thank you for a really useful bit of code!

 

 

--

You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


Paul Waby

unread,
Oct 23, 2023, 11:05:03 AM10/23/23
to E-Prime
Hi,

I have been using the CountDownClock.es code from PST to use for a 2 mins trial list to terminate after 2 mins and proceed to the next block to start again. But on the 2nd block the timer doesn't start again and the trials flick through without asking for user input (to answer sums). I can't see why it doesn't work for the 2nd block and thereafter, any ideas anyone please?

I tried using new variables thinking it's still set to zero so it doesn't run properly after the 1st block. Annoying problem but probably something silly I can’t see.

I terminate the current triallist/block when the countdown reaches zero.


Code -


Inline before slide, start the counter -

lnStartTime = Slide1.OnsetTime


Slide, then


Inline after slide

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' VARIABLE DECLARATIONS AND SETTINGS

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Declare variable for the end time

Dim lnEndTime As Long

'Declare variable for total duration

Dim lnTotDuration As Long



'Set the total duration of the trial

lnTotDuration = 30000

'Set the EndTime equal to the StartTime plus the TotDuration

lnEndTime = lnStartTime + lnTotDuration


'Set the variable that will start your count down clock

'in this case, the clock will start after 5000ms

Dim lnCountAfterTime As Long

lnCountAfterTime = lnStartTime + 0


'Initialize variables to zero

lnCountTime = 0

lnpreviousCountTime = 0




'Counter to debug the amount of times the screen is redrawn

Dim intDrawCount As Integer


'Get access to the Text2 SlideText object in order to 

'place text and redraw the object

Dim T2 As SlideText

Set T2 = CSlideText(Slide1.States.Item("Default").Objects("Text2"))



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' LOOP AND DISPLAY COUNTER IF NECESSARY

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


'Loop until EndTime has been reached, or the subject has responded

Do While (Clock.Read <= lnEndTime) And (Slide1.InputMasks.Ispending())


'If the count down time has been reached, display the counter

If Clock.Read >= lnCountAfterTime Then


'Calculate the amount of time left in seconds

lnCountTime = (lnEndTime - Clock.Read) / 1000

'Convert to an integer

lnCountTime = CInt(lnCountTime)


'If a second has elapsed, previousCountTime will not be the same 

'as CountTime, so draw the new counter

If lnpreviousCountTime <> lnCountTime Then

'Set the appropriate text

If lnCountTime = 60 Then

T2.Text = "Hurry Up, You have " & lnCountTime & " seconds left."

Else

T2.Text = "You have " & lnCountTime & " seconds left."

End If

'Force a redraw

T2.Draw

'Add 1 to the drawing counter

intDrawCount = intDrawCount + 1

End If

'Set the previousCountTime equal to the current CountTime

lnpreviousCountTime = lnCountTime

End If


Loop


If lnCountTime = 0 Then

T2.Text = "0 seconds left."

lnCountTime = Slide1.OffsetTime

TrialList.Terminate

End If



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' DEBUG AND RELEASE REFERENCES

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


'Calculate and debug.print the total time of the trial

'from the current time minus the StartTime

'Note: this value will only be close to 15000 when no

'response has been made for the entire trial; simply for error checking

Dim lnTotTime As Long

lnTotTime = Clock.Read - lnStartTime

Debug.Print "Total Trial Time = " & lnTotTime


'Debug the amount of times the screen was redrawn

'value should be the amount of seconds + 1 (to account for drawing zero)

Debug.Print "Redrawn " & intDrawCount & " times"


'Reset the .TEXT property of T2

T2.Text = ""

'Release references

Set T2 = Nothing



McFarlane, David

unread,
Dec 5, 2023, 4:42:43 PM12/5/23
to e-p...@googlegroups.com
It seems to me that the line

lnStartTime = Slide1.OnsetTime

should run *after* the Slide rather than before, as E-Prime does not set the current OnsetTime until the Slide runs. Otherwise, the first time through Slide1.OnsetTime is 0, the second time through it still has the value from the first time through, etc.

-- David McFarlane


On 2023-10-23 Mon 11:05 AM, 'Paul Waby' via E-Prime wrote:
> Hi,
> *
Reply all
Reply to author
Forward
0 new messages