Repeat a handler until time limit expires
Posted: Mon Oct 01, 2012 7:21 am
Hi all,
What is the best way to repeatedly summon a specific handler until a given length of time expires? I'm creating a program wherein I want a specific card to remain open for *up to* 8 seconds OR until they click a button to proceed. In other words, the card opens and remains fully open for up to 8 seconds, but if participants want to selectively advance they can press a button.
One of the major problems I'm having is that I need the handler to repeatedly check the elapsed time. If the time has not expired, then I need the exact same handler to run again. In this manner, the handler will once again check the time. If the time has still not expired, then I need the exact same handler to run again, etc. until the time has elapsed. If, during the course of the handler repeatedly running, I need the button which is clicked to tell the handler to STOP running.
The major issue is that repeatedly running a handler gives me a recursion limit reached error.
Here is some code to facilitate discussion:
I very much hope you can help me!
Thanks in advance.
What is the best way to repeatedly summon a specific handler until a given length of time expires? I'm creating a program wherein I want a specific card to remain open for *up to* 8 seconds OR until they click a button to proceed. In other words, the card opens and remains fully open for up to 8 seconds, but if participants want to selectively advance they can press a button.
One of the major problems I'm having is that I need the handler to repeatedly check the elapsed time. If the time has not expired, then I need the exact same handler to run again. In this manner, the handler will once again check the time. If the time has still not expired, then I need the exact same handler to run again, etc. until the time has elapsed. If, during the course of the handler repeatedly running, I need the button which is clicked to tell the handler to STOP running.
The major issue is that repeatedly running a handler gives me a recursion limit reached error.
Here is some code to facilitate discussion:
Code: Select all
on keeptrack6
global matlist1,testtemp,howlong,whichitem,timeoutRT,session,recall,numtrials,tempanswer,data,stopkeeptrack6,matlist2,matlist3,matlist4,matlist5,matlist6,subID,testtemp,matlist,dropstatus,matlists,stopkeeptrack7,firstkey,writetime,lagcond,checktime
if stopkeeptrack6 is false then --K
put (the ticks - timeoutRT) into checktime
if session = 1 then --a
put 480 into howlong
else
put 3600 into howlong
end if --a
if checktime > howlong then -- 8 seconds --A
if firstkey is true then --b
put ((the ticks - writetime)/60) & "," after data
put "no" & "," after data
end if --b
put cd fld "recall" & "," after data
put cd fld "recall" into tempanswer
put empty into cd fld "recall"
show cd fld "hide recall"
hide cd fld "hide definition"
hide cd fld "recall instructions"
hide cd fld "study instructions"
put item 2 of line 1 of testtemp into whichitem # item num
if (char 1 to 4 of item 1 of line 1 of tempanswer) = (char 1 to 4 of item 4 of line 1 of testtemp) then --Y ---> Answer Correct
add 1 to line whichitem of cd fld "dropstatus" of cd "main task materials"
if line whichitem of cd fld "dropstatus" of cd "main task materials" < item 5 of line 1 of testtemp then --X --> Answer correct, not reached criterion yet
put return & line 1 of testtemp after matlist1
opencard
else --X --> Answer correct and reached criterion
go to cd "confidence"
end if --X
else --if answer is incorrect Y
put return & line 1 of testtemp after matlist1
show cd fld "hide recall"
hide cd fld "hide definition"
hide cd fld "recall instructions"
hide cd fld "study instructions"
hide button "done with recall"
hide cd fld "recall instructions2"
wait 30 ticks
opencard
end if --Y
else #time limit not reached on test trial --A
keeptrack6
end if --A
end if --K
end keeptrack6
Thanks in advance.