can't use response attributes in inline code

669 views
Skip to first unread message

Ingrid

unread,
May 4, 2016, 9:44:57 AM5/4/16
to E-Prime
Hi,

Some background on my experiment: The user gets to solve a word puzzle during Slide3, pressing a button when knowing the answer, just to get the response time, and then saying the answer. Then the experimenter enters if the response was correct or incorrect during the next text display Blank7.

But the problem is I also want to let the experimenter enter the response on the previous Slide3, in case the user forgets to press the button for reaction time (and just says the word instead) - just as a precaution.
If this be the case, Blank7 is skipped and Blank7.RESP is thus never created. I would prefer to have all responses in the Blank7.RESP column in the edat-file, so I am now, in two inline scripts in the same procedure as Slide3 and Blank7, trying to create the attribute Blank7.RESP and set it to the same value as Slide3.RESP.

Below is one inline that I've put directly after Slide3. Also, I have set the script generation to BeforeObjectRun and AfterObjectRun (have also tried various alternatives here, but I can't seem to get it to help).

Debug.Print c.GetAttrib("Slide3.RESP")

If c.GetAttrib("Slide3.RESP") = "r" Then
    c.SetAttrib "Blank7.RESP", "r"
    Debug.Print "Slide3=r"
ElseIf c.GetAttrib("Slide3.RESP") = "f" Then
    c.SetAttrib "Blank7.RESP", "f"
    Debug.Print "Slide3=f"
ElseIf c.GetAttrib("Slide3.RESP") = "1" Then
    Debug.Print "Slide3.RESP=1"
Else Debug.Print "something else"
End If



The rest of my code is in an inline at the end of the procedure (and thus after both Slide3 and Blank7):

' Counting number of correct and incorrect answers
If c.GetAttrib("Blank7.RESP") = "r" Then
    Correct = Correct + 1
    Incorrect = 0
ElseIf c.GetAttrib("Blank7.RESP") = "f" Then
    Incorrect = Incorrect + 1
End If

If Incorrect > 4 Then
    Ordlista.Terminate
End If

If Slide3.RESP = "1" Then
    Responses = Responses + 1
End If

From the debugging in the first inline, I can see that Slide3.RESP never has the value that it should (r, f or 1), so the else clause is always executed.
And when I try to answer during Slide3, i.e. the special case that I want to get to work, the experiment ends and I get the error message: No such attribute "Blank7.RESP"

I'd be very grateful for some help on this.
Best, Ingrid

David McFarlane

unread,
May 5, 2016, 11:48:54 AM5/5/16
to e-p...@googlegroups.com
Sigh. I sound like a broken record, because this same issue keeps
coming up here. This looks like another example where the combination
of GeneratePreRun, PreRelease, and InLine code causes problems. Go to
the E-Prime Knowledge Base at the PST website, do a search on those
terms, and take it from there. The Experiment Advisor in EP2.0.10
Professional will also warn you about this, you should heed that warning.

<editorial>
Before EP2.0.10, inline code pretty much worked as users expected, but
getting critical timing to work took a lot of effort. With EP2.0.10,
critical timing got a lot more effortless, at the expense of tripping up
some users' expectations of inline code. Sometimes you just can't win.
</editoria>


On another note, I never understand why users persist in using attribute
values when they could much more easily use the values of the underlying
object properties directly. Yes, I generally discourage *assigning*
*control* values directly to object properties (see
https://groups.google.com/d/topic/e-prime/RBwU6WDdlG8 ), but I do not
apply that to assigning values to *response* properties, nor to merely
*using* the values. So why not rewrite your inline code as

Debug.Print Slide3.RESP
If Slide3.RESP = "r" Then
Blank7.RESP = "r"
Debug.Print "Slide3=r"
ElseIf Slide3.RESP = "f" Then
Blank7.RESP = "f"
Debug.Print "Slide3=f"
ElseIf Slide3.RESP = "1" Then
Debug.Print "Slide3.RESP=1"
Else Debug.Print "something else"
End If

and

' Counting number of correct and incorrect answers
If Blank7.RESP = "r" Then
Correct = Correct + 1
Incorrect = 0
ElseIf Blank7.RESP = "f" Then
Incorrect = Incorrect + 1
End If
If Incorrect > 4 Then
Ordlista.Terminate
End If
If Slide3.RESP = "1" Then
Responses = Responses + 1
End If
c.SetAttrib "Blank7.RESP", Blank7.RESP ' just in case

? Hmm, as long as I've gone that far, might as well replace those
If-ElseIf structures with Select-Case (and tighten up the code just a
bit with a couple single-line If-Thens) ...

Debug.Print Slide3.RESP
Select Case Slide3.RESP
Case "r"
Blank7.RESP = "r"
Debug.Print "Slide3=r"
Case "f"
Blank7.RESP = "f"
Debug.Print "Slide3=f"
Case "1"
Debug.Print "Slide3.RESP=1"
Case Else
Debug.Print "something else"
End Select

and

' Counting number of correct and incorrect answers
Select Blank7.RESP
Case "r"
Correct = Correct + 1
Incorrect = 0
Case "f"
Incorrect = Incorrect + 1
Case Else
' do nothing
End Select
If Incorrect > 4 Then Ordlista.Terminate
If Slide3.RESP = "1" Then Responses = Responses + 1
c.SetAttrib "Blank7.RESP", Blank7.RESP ' just in case


-- David McFarlane
> *No such attribute "Blank7.RESP"*I'd be very grateful for some help on this.
> Best, Ingrid

David McFarlane

unread,
May 5, 2016, 11:55:12 AM5/5/16
to e-p...@googlegroups.com
Oh, you should also look at the thread at
https://groups.google.com/d/topic/e-prime/IV1KWxm3Q-U .

-- David McFarlane

Ingrid

unread,
May 10, 2016, 3:25:16 AM5/10/16
to E-Prime
Thanks a lot for all the help! I'd actually missed the basic fact that an attribute and an object property isn't the same thing. I thought I was actually changing the object properties by using attributes. So I changed my code according to your suggestion and put all the code in one inline at the end of the procedure. It actually didn't work when I put the first script part after Slide3, which I thought was a bit strange (even with BeforeObjectRun), but as I got it working easily just by moving everything to the same place I didn't bother investigating that very much.

So now the script works using both TopOfProcedure or BeforeObjectRun. But I must say this thing about Script Generation is rather a complicated matter to me. I'd tried to read up on it before asking my question, and thought I'd got the basic hang of it, but it seems I should give it another go!

Thanks again!
Ingrid

David McFarlane

unread,
May 10, 2016, 6:00:27 PM5/10/16
to e-p...@googlegroups.com
Ingrid,

Yes. When you moved your code to an InLine that comes after the object
that follows your Slide3 (i.e., after your Blank7), you basically
achieved the same effect as you would by setting PreRelease of Slide3 to
0 (I assume that you left PreRelease of everything at "(same as duration)").

Glad you got it to work.

-- David McFarlane
Reply all
Reply to author
Forward
0 new messages