Global variable script problem: type mismatch

743 views
Skip to first unread message

Recursion

unread,
Jul 25, 2009, 10:52:39 AM7/25/09
to E-Prime
I'm having a little problem with a script I wrote to keep track of
subject responses. Just to clear up any ambiguity with the variable
names, know that a keyboard response of '1' indicates a "positive"
response--the subject agrees with the statement on screen. A keyboard
response of '4' is a negative response--disagreement.

The problem is that there is a time-out condition--subjects only have
5 seconds to respond. The script works fine, except in cases where the
slide is allowed to timeout. In such a case, I get a type mismatch
error pointing to the first line in the If statement. Here's the
script:

-------------------------------------------------------------------------------------------
'Calculates total trial number
'Calculates total number of positive subject resp
'Calculates total number of negative subject resp
g_nTotalTrials = g_nTotalTrials + 1

If InputSlide.RESP = 1 Then
g_nTotalPositive = g_nTotalPositive + 1
ElseIf InputSlide.RESP = 4 Then
g_nTotalNegative = g_nTotalNegative + 1
Else
End If

c.SetAttrib "TrialCounter", g_nTotalTrials 'set for display and
logging
c.SetAttrib "TotalPositive", g_nTotalPositive 'set for display and
logging
c.SetAttrib "TotalNegative", g_nTotalNegative 'set for display and
logging
------------------------------------------------------------------------------------------

Perhaps I should consider some sort of typecast? Is a failure to
respond of type bool? Come to think of it, I'm not entirely certain of
this. I have another script that runs a contingent branch on the slide
objects used for feedback. Here's that script:

----------------------------------------------
If InputSlide.RESP = "1" Then
Feedback1.Run c
Else
Feedback2.Run c
End If
----------------------------------------------

I'd like to change this to lead to a third feedback slide object in
the event that the subject fails to respond within 5 minutes--but to
do this I need to know how a failure to respond in time is even coded--
what its type is.

Thanks so much!
S

liwenna

unread,
Jul 26, 2009, 5:06:32 AM7/26/09
to E-Prime
Hello S.

No e-prime at hand at the moment (nor in the coming week), but a first
thing that you could try is to change the elseif in the second
statement of the if-part in if:

If InputSlide.RESP = 1 Then
g_nTotalPositive = g_nTotalPositive + 1
If InputSlide.RESP = 4 Then
g_nTotalNegative = g_nTotalNegative + 1
Else
End If

It's a hunch but I think I remember that doing just that fixed a
similar problem for me at times.

Best regards,

liwenna

liwenna

unread,
Jul 26, 2009, 5:10:35 AM7/26/09
to E-Prime
Ow and for the second question...

----------------------------------------------
If InputSlide.RESP = "1" Then
Feedback1.Run c
If InputSlide.RESP = "4" Then
Feedback2.Run c
Else
Feedback3.run c
End If
----------------------------------------------

Of there's only two allowable inputs (1 and 4) then a non-response
should automatically sort under 'Else' and show the third
feedbackslide. Alternatively you could try

If InputSlide.RESP = "" Then
Feedback3.run c

but not entirely sure whether that will work.

Again, no e-prime at hand so not sure if it works, but I think it
should.

Best regards,

liwenna

Recursion

unread,
Jul 26, 2009, 12:58:51 PM7/26/09
to E-Prime
Turns out it was a stupid mistake on my part! I neglected to add
quotes around the subject response in the script that increments the
global variables. You do get an error here without an ElseIf, though.
Thanks so much for your help, Liwenna! I really appreciate it.
Reply all
Reply to author
Forward
0 new messages