Hi Camila,
If -then statements come in two forms in e-prime. If F and THEN are written on the same line (as in: If c.getAttrib ("Correct") = 6 Then CounterStimulusType6 = CounterStimulusType6 + 1) e-prime will execute them as they are encountered. This way you can 'attach' one 'THEN action' to an 'IF'. However, if you need more 'THEN actions', or if you also the ELSE option as you do, you'll need to 'break' the IF THEN line over multiple lines. In that case e-prime requires an 'END IF' after the complete set of THEN/ELSE actions attached to a single "IF"-statement. In your script his happens when you start redirecting e-prime to labels. For instance:
If (CounterStimulusType1 >= 6) And (CounterStimulusType2 >= 6) Then
GoTo LabelShape
Else
GoTo LabelColor
^ this piece of code needs to end with an END IF for e-prime to accept. HOWEVER... it may be the canse that (and no e-prime on the computer were I am no so can't test but I thin that) as soon as the GOTO labelshape is encountered, the program will move to the label and would not even reach the END IF even if you would add it (not sure, may also be that it starts moving only when it reaches the END IF).
In any case: the simple solution (even though it probably isn't the preferred practice by professional programmers) is to rewrite your statements so that each only takes a single line:
If (CounterStimulusType1 >= 6) And (CounterStimulusType2 >= 6) Then GoTo LabelShape
If(CounterStimulusType2 >= 6) Then GoTo LabelShape
If(CounterStimulusType3 >= 6) Then GoTo LabelShape
If (CounterStimulusType4 >= 6) Then GoTo LabelShape
If (CounterStimulusType5 >= 6) Then GoTo LabelShape
If (CounterStimulusType6 >= 6) Then GoTo LabelShape
GoTo LabelColor
-> if none of the 'counterstimulustypeX' >= 6 are met, the GOTO labelcolor will be reached and e-prime will move there.
Notes: >= may as well just be =, cause I'd guess that the program will not return here once 6 is reached (i.e. >6 cannot occur?). You may want to look into loops to replace an 'x' or other placeholer with the numbers 1-6 and have a briefer piece of code - but that's more aesthetic than anything else. The first line of the above piece (If (CounterStimulusType1 >= 6) And (CounterStimulusType2 >= 6) ) also seems redundant -> if the second part of the IF statement is true ((CounterStimulusType2 >= 6) ) the next line will take care of executing the same THEN action (goto labelshape).
This is just a quick and dirty solution but I hope it gets you going again :)
Best,
Anne-Wil
On Tuesday, 27 January 2015 13:52:17 UTC, Camila Martínez wrote:
Hi,
I am trying to set an experiment with the condition that after 6 correct answers, it jumps to the next Trial Procedure.
I found a script here, I made some changes trying to fix the problem, but it doesn't run, and an error is shown with 'Encountered: End sub, Expecting: End If'
This is the only inline I added to the experiment, and in order to go from one Trial Procedure to the next, I put labels.
Dim CounterStimulusType1 As Integer
Dim CounterStimulusType2 As Integer
Dim CounterStimulusType3 As Integer
Dim CounterStimulusType4 As Integer
Dim CounterStimulusType5 As Integer
Dim CounterStimulusType6 As Integer
Trial:
If c.getAttrib ("Correct") = 1 Then CounterStimulusType1 = CounterStimulusType1 + 1
If c.getAttrib ("Correct") = 2 Then CounterStimulusType2 = CounterStimulusType2 + 1
If c.getAttrib ("Correct") = 3 Then CounterStimulusType3 = CounterStimulusType3 + 1
If c.getAttrib ("Correct") = 4 Then CounterStimulusType4 = CounterStimulusType4 + 1
If c.getAttrib ("Correct") = 5 Then CounterStimulusType5 = CounterStimulusType5 + 1
If c.getAttrib ("Correct") = 6 Then CounterStimulusType6 = CounterStimulusType6 + 1
If (CounterStimulusType1 >= 6) And (CounterStimulusType2 >= 6) Then
GoTo LabelShape
Else
GoTo LabelColor
If(CounterStimulusType2 >= 6) Then
GoTo LabelShape
Else
GoTo LabelColor
If(CounterStimulusType3 >= 6) Then
GoTo LabelShape
Else
GoTo LabelColor
If (CounterStimulusType4 >= 6) Then
GoTo LabelShape
Else
GoTo LabelColor
If (CounterStimulusType5 >= 6) Then
GoTo LabelShape
Else
GoTo LabelColor
If (CounterStimulusType6 >= 6) Then 'if either one hasn't reached 6
GoTo LabelShape
Else
GoTo LabelColor
End If
I have three of this inlines, changing the label names. One for each Trial Procedure.
It would be very helpful I you have an idea.
Thank you very much,
Camila M