"Type Mismatch" error upon slide timeout

David McFarlane mcfarla9 at msu.edu
Tue Sep 25 19:48:23 UTC 2012


Erin,

Sigh.  Please, please, please folks:  (1) Do *not* apply any 
formatting to text in your posts, it makes it illegible in some 
e-mail readers.  Just use plain text.  (2) OTOH, *do* indent your 
code fragments for readability, e.g.,

     If Stimulus.RESP = 1 Then
         nPoints = nPoints + 1
     Else
         nPoints = nPoints + 0
     End If
     c.SetAttrib "CurrentPoints", nPoints

Now, to start with, why in the world would you have a line like

     nPoints = nPoints + 0

which produces absolutely no effect?!  The following simplified code 
would do the same:

     If (Stimulus.RESP = 1) Then nPoints = nPoints + 1
     c.SetAttrib "CurrentPoints", nPoints

Now, to your problem.  The RESP property of Stimulus has type String, 
not Integer.  Because VBA/E-Basic, when possible, does automatic type 
conversion (which just allows programmers to get sloppy), that works 
fine as long as RESP happens to contain text that will convert to an 
integer.  But when you get no response, RESP contains the null sting 
"", and that does *not* convert to an integer.  Thus, the "Type 
Mismatch" error, easily understood by those of us who grew up with 
proper strongly-typed languages (e.g., Fortran, Pascal, C).

The solution?  Here are better tests for *presence* of a response:
     - If (x.RESP <> "") ...
     - If (Len(x.RESP) > 0) ...,  or,  If Len(x.RESP) ...
     - If (x.RTTime <> 0)  ...,  or,  If (x.RTTime) ...
     - If (x.InputMasks(1).Count > 0) ...,
       or,  If x.InputMasks(1).Count ...  (but only for given mask)

Simply invert these to make tests for *absence* of a response.  And 
as indicated by these examples, because VBA/E-Basic treats 0 as False 
and any non-0 value as True, in some cases you need not make the 
comparison test explicit (although most users may find that 
discomforting).  (I used to also include the test "If (x.RT) ...", 
but I recently discovered that, in the unlikely case that RTTime = 
OnsetTime, RT would be 0 even with a response.)

So in your case, this comes down to just, e.g.,

     If Stimulus.RTTime Then nPoints = nPoints + 1
     c.SetAttrib "CurrentPoints", nPoints

-----
David McFarlane
E-Prime training 
online:  http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter:  @EPrimeMaster (https://twitter.com/EPrimeMaster)

/----
Stock reminder:  1) I do not work for PST.  2) PST's trained staff 
take any and all questions at 
http://support.pstnet.com/e%2Dprime/support/login.asp , and they 
strive to respond to all requests in 24-48 hours -- this is pretty 
much their substitute for proper documentation, so make full use of 
it.  3) In addition, PST takes questions at their Facebook page 
(http://www.facebook.com/pages/Psychology-Software-Tools-Inc/241802160683 
), and offers several instructional videos there and on their YouTube 
channel (http://www.youtube.com/user/PSTNET ) (no Twitter feed yet, 
though).  4) If you do get an answer from PST staff, please extend 
the courtesy of posting their reply back here for the sake of others.
\----


At 9/25/2012 03:17 PM Tuesday, Erin wrote:
>I have an experiment where the subject has 3 seconds to make a 
>response each trial, after which the trial times out.  On the 
>Feedback slide, I want to display the number of trials completed, 
>not counting trials that timed out.
>
>To do this, I added an inline to my experiemnt. I noticed in my data 
>output that when Stimulus.RESP = 1, the trial has been completed. 
>So, this is the inline text I used:
>
>If Stimulus.RESP = 1 Then
>nPoints = nPoints + 1
>Else
>nPoints = nPoints + 0
>End If
>c.SetAttrib "CurrentPoints", nPoints
>
>I also went to view -> script, and added "Dim nPoints as integer" in 
>the user script.
>
>When I run my experiment, it successfully displays a trial count on 
>the feedback slide as long as I make either correct or incorrect 
>responses. However, as soon as I let a trial time out, I get the 
>following error, and the program terminates:
>
>The following Runtime error occurred:
>Type Mismatch
>line: 640
>error number: 13
>
>I have tried adjusting a few things, but with no success.  Does 
>anyone have experience getting around this error? thanks so much
>
>Erin

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



More information about the Eprime mailing list