Setting a time limit on a procedure
 
 
 
PST User Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Setting a time limit on a procedure Expand / Collapse
Author
Message
Posted 5/20/2008 4:14:26 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/11/2008 5:44:13 PM
Posts: 6, Visits: 14
I have yet another question regarding my Information Search Task. In this task participants read articles that they navigate via a main menu. All the objects for this task are contained within a single Procedure. One of the dependent variables is how long the participants persist at the task and as such, the instructions at the beginning of the task are "This task has no time limit". However, I've found that some participants are persisting longer than expected which impedes on the rest of the experimental tasks. Consequently, I've been stopping participants after 20 minutes. For now this is quite sufficient, however, in the future, I plan to have another task immediately follow the Information Search Task on E-Prime and, therefore, I would like the Info task to stop after 20 minutes without my intervention.

Is it possible to set a time limit on a procedure? Is it possible to design the study so that after 20 minutes the task "times out"?.

Thank you!!

Karine

Post #1571
Posted 6/11/2008 4:09:11 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/11/2008 5:44:13 PM
Posts: 6, Visits: 14
I am still hoping to get feedback on this post. Thank you so very much:

radool (5/20/2008)
I have yet another question regarding my Information Search Task. In this task participants read articles that they navigate via a main menu. All the objects for this task are contained within a single Procedure. One of the dependent variables is how long the participants persist at the task and as such, the instructions at the beginning of the task are "This task has no time limit". However, I've found that some participants are persisting longer than expected which impedes on the rest of the experimental tasks. Consequently, I've been stopping participants after 20 minutes. For now this is quite sufficient, however, in the future, I plan to have another task immediately follow the Information Search Task on E-Prime and, therefore, I would like the Info task to stop after 20 minutes without my intervention.

Is it possible to set a time limit on a procedure? Is it possible to design the study so that after 20 minutes the task "times out"?.

Thank you!!

Karine

Post #1663
Posted 6/12/2008 2:18:37 PM
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: Yesterday @ 5:08:57 PM
Posts: 170, Visits: 490
Karine,

Thanks for refreshing your post, I wanted to answer this earlier but got busy with other things.

You can do this with a bit of inline script and some global variables.

First, in the global User Area of your script (see sections 4.3 and 4.4 of the E-Prime User's Guide for more on this), define a global variable for the exit time,

Dim tExit as Long

Next, let's suppose that the task you want to time-limit is run by a list object that repeatedly calls a single procedure, and let's call those ExptList and ExptProc. Now, in an inline before ExptList, set the exit time with

tExit = Clock.Read + 20000

Then, in an inline at the end of ExptProc, do something like

If Clock.Read >= tExit Then ExptList.Terminate

That will end the list when the subject reaches the time limit. (Depending on the structure of your program, the Then clause might instead have to be something like Goto ..., or Exit Sub, etc.) You can find out more about this by browsing the online E-Basic help.


For those interested, a few further points on programming style:

First, the number 20000 above is what we call a "magic number", and that is bad practice. Better to make a constant and use that, e.g.,

' in user global area:
Const TimeLimit as Long = 20000

' in inline just before ExptList:
tExit = Clock.Read + TimeLimit

Or, add TimeLimit as an attribute in a list object that encloses ExptList, and set the exit time with

' in inline just before ExptList:
tExit = Clock.Read + c.GetAttrib("TimeLimit")

Second, many programmers would record the starting time (e.g., t0 = Clock.Read), and then repeatedly test the current time against the starting time plus the time limit (e.g., If Clock.Read >= t0 + TimeLimit). That seems redundant to me, so I like to do my exit time calculation just once at the start.

-- David McFarlane, Professional Faultfinder
Post #1671
Posted 6/12/2008 2:23:43 PM
Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: Yesterday @ 5:08:57 PM
Posts: 170, Visits: 490
Karine,

Oops, you said the time limit was 20 minutes, not 20 seconds! So the correct "magic number" would be 20 * 60 * 1000 = 1200000, e.g.,

Const TimeLimit as Long = 20 * 60 * 1000

(yes, you can do calculations as part of the constant declaration, which better documents everything and reduces mistakes).

-- David McFarlane, Professional Faultfinder
Post #1672
« Prev Topic | Next Topic »


Permissions Expand / Collapse

All times are GMT -5:00, Time now is 4:55pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.062. 10 queries. Compression Disabled.