Using the recursive loop to rerun a List

324 views
Skip to first unread message

MarcL

unread,
Oct 22, 2014, 11:30:49 AM10/22/14
to e-p...@googlegroups.com
Hi there,

I am working on an experiment, in which the participant at one point, during a practice trial, will be required to miss less than a certain number of items in order to get through to the next phase.

Thus, I have created a List and Procedure for this task inside a procedure that I am calling on the last List column, unless less then 3 Items have been missed.

I use the following code to terminate the list, in case the criterion is met. This works fine.



TotalTrials = TotalTrials + 1

If Triade.resp = "" Then
    MissesActiveTrial = MissesActiveTrial + 1
    MissesTotal = MissesTotal + 1 'Total misses in all practice trials put together
End If

If TotalTrials = 10 Then
    If MissesActiveTrial < 3 Then TrialRAT.Terminate
End If



However, if the criterion is not met, Eprime crashes.
Is there any List resetting etc. necessary in order to repeat a List? I think I read, that recursive programming is not possible via Eprime, at least in this way, but I can't seem to be able to find where I might have read that, and it just seems counterintuitive given the fact that there is the "Recursive Loop" thing in the first place. And the fact, that it would be a way more elegant way to do it this way than via GoTo Label.


Thanks a lot!
Marc

MarcL

unread,
Oct 23, 2014, 10:35:45 AM10/23/14
to e-p...@googlegroups.com
I'd still appreciate, if someone has an elegant way of recursive programming in eprime, but for now I solved it otherwise!

David McFarlane

unread,
Oct 23, 2014, 11:20:21 AM10/23/14
to e-p...@googlegroups.com
Marc,

Well, don't keep us in suspense, please do tell your solution!

Thanks,
-- David McFarlane

MarcL

unread,
Oct 26, 2014, 6:36:06 AM10/26/14
to e-p...@googlegroups.com
It's unspectacular though ;)

The 'design' of the whole task looks something like this (RAT = Remote Association Task):

StartOver (Label)
RAT-Task (List)
Instructions (Procedure)
WhereTo (Inline)
General Instructions
JumpToTask (Inline) 
TooSlow (Label) 
'You will have to practice again' Instructions
StartPractice (Label) 
RAT-Trial (List) 
(--- all the task related stuff, then ---) 
CheckPerformance (Inline) 
RAT-Test (List)
CheckPerformance2 (Inline)

I am defining a boolean variable, let's call it "PracticedBefore" in the user script. I am setting it to false by default.

WhereTo checks, if PracticedBefore == false. If not, it jumps to "TooSlow", and resets PracticedBefore to false, also resets the counter for missed trials to 0. 
JumpToTask just jumps to StartPractice no matter what.

CheckPerformance checks, as outlined in my first posting, the performance in that very practice task, as well as overall practice performance. 
If the participant misses more than 2 RAT items, PracticedBefore is set to true, and RAT-Task, the overall List, is terminated by RAT-Task.Terminate.

CheckPerformance2 checks, whether PracticedBefore == false. If so, it jumps to StartOver and everything happens again ;)


pretty straight forward, I'd really appreciate if the E-Prime developers would add a loop feature, that can loop a list as often as I want it to (or eternally), and depend on the programmer terminating the List via .Terminate. This would keep adaptive experiments wayyyy more simple and less confusing.



I hope I forgot nothing in my explanation, as I don't have eprime with me now...I'm pretty new to Eprime, so, again, if there is a more clever solution please tell me!

David McFarlane

unread,
Oct 30, 2014, 5:12:30 PM10/30/14
to e-p...@googlegroups.com
Marc,

Thanks for posting your solution. I had to scratch my head trying to
follow your posted structure, partly because of all the extraneously
blank lines, and because I think the indentation was off. Here is my
attempt to correct that, also renaming the objects to directly
indicate their type:

Global:
PracticedBefore = False

StartOverLabel
RAT-TaskList
InstructionsProc
WhereToCode:
If PracticedBefore Then
PracticedBefore = False
MissedTrialCount = 0
Goto TooSlow
GeneralInstructionText
JumpToTaskCode: Goto StartPractice
TooSlowLabel
PracticeAgainText
StartPracticeLabel
RAT-TrialList
(--- all the task related stuff, then ---)
CheckPerformanceInline:
If {participant misses more than 2 RAT items}
PracticedBefore = True
RAT-TaskList.Terminate
RAT-TestList
CheckPerformance2Code: If (PracticedBefore = False) Then Goto StartOver

So, I am glad this works for you, but it does seem overly tangled to
me, though I do not have any idea how to untangle it because I am not
quite clear from all this what you intend the program to do. Offhand
I would think that you want the subject to get instructions only once
at the start, and then present a "Too Slow" message and redo the
practice until they reach criterion -- if that is all that you want
then I might have some ideas.

>... I'd really appreciate if the E-Prime developers would add a loop
>feature, that can loop a list as often as I want it to (or
>eternally), and depend on the programmer terminating the List via
>.Terminate. This would keep adaptive experiments wayyyy more simple
>and less confusing.

I think your program illustrates that E-Prime already has such a
feature, e.g., RAT-TaskList.Terminate. What am I missing?

-- David McFarlane

MarcL

unread,
Oct 30, 2014, 7:07:19 PM10/30/14
to e-p...@googlegroups.com
Hi David, 

thanks for your comments!
Sorry for the mess, indentation works here, though, I'm not sure what I might have done wrong (?)

You got me right, though. All I want is to redo the practice list until a criterion is met. I think what makes it seem tangled is the complicated way I am dealing with instructions, I found a better way for this already (presenting the instructions in a separate list column, the weight of which is set to 0 after presentation). I have not, though, for re running a list - is there indeed a different way than jumping to a label in front of that list?

If I was working in, say, Basic of Visual Basic, and a List would be a function in my application, I am looking for the E-Prime analogy to

Do
PracticeTrial()
Loop Until Criterion = true

Thanks for your efforts!!
Marc

David McFarlane

unread,
Oct 31, 2014, 12:37:01 PM10/31/14
to e-p...@googlegroups.com
Marc,

So, in Visual Basic you might do

Do
PracticeTrial()
Loop Until (Criterion = True)

and the equivalent in E-Prime would be something like

PracticeTrialList
PracticeTrialProc
{PracticeTrial stuff...}
CriterionCode: If {criterion met} Then
PracticeTrialList.Terminate

For this to work, have PracticeTrialList set with one row using
PracticeTrialProc, and either set the row Weight to some large number
(e.g., 10000), or set PracticeList to exit after some large number of
cycles, samples, or seconds (in the List properties). Yes, you
cannot set a List to run for an indefinite number of trials, you do
have to give it some upper bound, but you can make that very
large. Does that sound reasonable, or am I still missing something?

Actually, though, from what you describe you really want to test
criterion for *blocks* of trials, as well as showing a message before
running another practice block, in which case in Visual Basic you
might do something more like

GeneralInstructions()
Do ' exit from within loop
InitializeTrialBlock()
For i = 1 to nTrialsPerBlock
PracticeTrial()
Next i
If (Criterion = True) Then Exit Do
PracticeAgainMessage()
Loop

And with that in mind I might restructure your program as follows:

GeneralInstructionText
PracticeBlockList
PracticeBlockProc
PracticeTrialList
PracticeTrialProc
...
BlockCriterionCode:
If {participant misses FEWER than 2 RAT items} Then
PracticeBlockList.Terminate
Goto PracticeBlockEndLabel
PracticeAgainText
PracticeBlockEndLabel

So PracticeTrialList does all the trials for one block,
PracticeBlockProc is set to run some large number of blocks of these
trials, and BlockCriterionCode terminates PracticeBlockList and skips
past PracticeAgainText if criterion is met, otherwise it shows
PracticeAgainText and then runs another block. Do you think this would work?

Thanks,
-- David McFarlane

MarcL

unread,
Nov 1, 2014, 6:54:23 AM11/1/14
to e-p...@googlegroups.com
Hi David,

this would work for sure, and is exactly what I have been looking for :) 

Thank you very much!! My missing link was the idea to set the weight to a very large number to achieve a "quasi loop". 
I will definately make a lot of use of this in the future!

Marc
Reply all
Reply to author
Forward
0 new messages