<div>David,</div><div>Thank you very much for the help and the detailed explanation about type. I had never been exposed to programming before using E-Prime, so the explanation is very helpful. Thanks again!!</div><div><br></div><div>Erin</div><div><br></div><div><br></div><br><br>On Tuesday, September 25, 2012 3:48:33 PM UTC-4, McFarlane, David wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Erin,
<br>
<br>Sigh. Please, please, please folks: (1) Do *not* apply any
<br>formatting to text in your posts, it makes it illegible in some
<br>e-mail readers. Just use plain text. (2) OTOH, *do* indent your
<br>code fragments for readability, e.g.,
<br>
<br> If Stimulus.RESP = 1 Then
<br> nPoints = nPoints + 1
<br> Else
<br> nPoints = nPoints + 0
<br> End If
<br> c.SetAttrib "CurrentPoints", nPoints
<br>
<br>Now, to start with, why in the world would you have a line like
<br>
<br> nPoints = nPoints + 0
<br>
<br>which produces absolutely no effect?! The following simplified code
<br>would do the same:
<br>
<br> If (Stimulus.RESP = 1) Then nPoints = nPoints + 1
<br> c.SetAttrib "CurrentPoints", nPoints
<br>
<br>Now, to your problem. The RESP property of Stimulus has type String,
<br>not Integer. Because VBA/E-Basic, when possible, does automatic type
<br>conversion (which just allows programmers to get sloppy), that works
<br>fine as long as RESP happens to contain text that will convert to an
<br>integer. But when you get no response, RESP contains the null sting
<br>"", and that does *not* convert to an integer. Thus, the "Type
<br>Mismatch" error, easily understood by those of us who grew up with
<br>proper strongly-typed languages (e.g., Fortran, Pascal, C).
<br>
<br>The solution? Here are better tests for *presence* of a response:
<br> - If (x.RESP <> "") ...
<br> - If (Len(x.RESP) > 0) ..., or, If Len(x.RESP) ...
<br> - If (x.RTTime <> 0) ..., or, If (x.RTTime) ...
<br> - If (x.InputMasks(1).Count > 0) ...,
<br> or, If x.InputMasks(1).Count ... (but only for given mask)
<br>
<br>Simply invert these to make tests for *absence* of a response. And
<br>as indicated by these examples, because VBA/E-Basic treats 0 as False
<br>and any non-0 value as True, in some cases you need not make the
<br>comparison test explicit (although most users may find that
<br>discomforting). (I used to also include the test "If (x.RT) ...",
<br>but I recently discovered that, in the unlikely case that RTTime =
<br>OnsetTime, RT would be 0 even with a response.)
<br>
<br>So in your case, this comes down to just, e.g.,
<br>
<br> If Stimulus.RTTime Then nPoints = nPoints + 1
<br> c.SetAttrib "CurrentPoints", nPoints
<br>
<br>-----
<br>David McFarlane
<br>E-Prime training
<br>online: <a href="http://psychology.msu.edu/Workshops_Courses/eprime.aspx" target="_blank">http://psychology.msu.edu/<wbr>Workshops_Courses/eprime.aspx</a>
<br>Twitter: @EPrimeMaster (<a href="https://twitter.com/EPrimeMaster" target="_blank">https://twitter.com/<wbr>EPrimeMaster</a>)
<br>
<br>/----
<br>Stock reminder: 1) I do not work for PST. 2) PST's trained staff
<br>take any and all questions at
<br><a href="http://support.pstnet.com/e%2Dprime/support/login.asp" target="_blank">http://support.pstnet.com/e%<wbr>2Dprime/support/login.asp</a> , and they
<br>strive to respond to all requests in 24-48 hours -- this is pretty
<br>much their substitute for proper documentation, so make full use of
<br>it. 3) In addition, PST takes questions at their Facebook page
<br>(<a href="http://www.facebook.com/pages/Psychology-Software-Tools-Inc/241802160683" target="_blank">http://www.facebook.com/<wbr>pages/Psychology-Software-<wbr>Tools-Inc/241802160683</a>
<br>), and offers several instructional videos there and on their YouTube
<br>channel (<a href="http://www.youtube.com/user/PSTNET" target="_blank">http://www.youtube.com/user/<wbr>PSTNET</a> ) (no Twitter feed yet,
<br>though). 4) If you do get an answer from PST staff, please extend
<br>the courtesy of posting their reply back here for the sake of others.
<br>\----
<br>
<br>
<br>At 9/25/2012 03:17 PM Tuesday, Erin wrote:
<br>>I have an experiment where the subject has 3 seconds to make a
<br>>response each trial, after which the trial times out. On the
<br>>Feedback slide, I want to display the number of trials completed,
<br>>not counting trials that timed out.
<br>>
<br>>To do this, I added an inline to my experiemnt. I noticed in my data
<br>>output that when Stimulus.RESP = 1, the trial has been completed.
<br>>So, this is the inline text I used:
<br>>
<br>>If Stimulus.RESP = 1 Then
<br>>nPoints = nPoints + 1
<br>>Else
<br>>nPoints = nPoints + 0
<br>>End If
<br>>c.SetAttrib "CurrentPoints", nPoints
<br>>
<br>>I also went to view -> script, and added "Dim nPoints as integer" in
<br>>the user script.
<br>>
<br>>When I run my experiment, it successfully displays a trial count on
<br>>the feedback slide as long as I make either correct or incorrect
<br>>responses. However, as soon as I let a trial time out, I get the
<br>>following error, and the program terminates:
<br>>
<br>>The following Runtime error occurred:
<br>>Type Mismatch
<br>>line: 640
<br>>error number: 13
<br>>
<br>>I have tried adjusting a few things, but with no success. Does
<br>>anyone have experience getting around this error? thanks so much
<br>>
<br>>Erin
<br>
<br></blockquote>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups "E-Prime" group.<br />
To post to this group, send email to e-prime@googlegroups.com.<br />
To unsubscribe from this group, send email to e-prime+unsubscribe@googlegroups.com.<br />
To view this discussion on the web visit <a href="https://groups.google.com/d/msg/e-prime/-/dKtmVZEFYOoJ">https://groups.google.com/d/msg/e-prime/-/dKtmVZEFYOoJ</a>.<br />
For more options, visit <a href="https://groups.google.com/groups/opt_out">https://groups.google.com/groups/opt_out</a>.<br />
<br />
<br />