<br><br>On Sunday, July 15, 2012 8:44:49 AM UTC-4, Anne-Wil wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><span style="color:rgb(7,55,99)">Hi David,</span><br style="color:rgb(7,55,99)"><br style="color:rgb(7,55,99)"><br style="color:rgb(7,55,99)"><span style="color:rgb(7,55,99)">In your code there seem to be some additions
compared to the original dohittest provided by PST, which I do not think
you need and may also form your problem.</span><br style="color:rgb(7,55,99)"><br style="color:rgb(7,55,99)"><span style="color:rgb(7,55,99)">As for the error code:
every IF THEN statement should be either placed on a single line or
closed with and END IF statement and similarly for conditional
statements like the DO UNTIL loop etc. The error occurs because there is
an END statement misplaced or missing, cause the program to get 'lost'.
</span><br style="color:rgb(7,55,99)"><br style="color:rgb(7,55,99)"><span style="color:rgb(7,55,99)">As for your specific code: I think you added several lines that involve a
do while statement and also have to do with the exact names of the
buttons that were clicked on (or perhaps they came with the post that you copied the script from :) ). </span><span style="color:rgb(7,55,99)">Neither of these, however, are needed for
your purpose (if I understood you correctly: you have two boxes, only
one needs to be clicked on and the name of that object needs to be
logged or uses for accuracy logging - right?). <br><br>For 'educational purposes' I'll post some remarks with the code that you posted and under that I'll post a new code suggestion. </span><br><br>'Designate "theState" as the Default Slide State, which is the<br> 'current, ActiveState on the Slide object "Stimulus"<br><br> Dim theState as SlideState<br> Set theState = Slide5.States("Default")<br><br> Dim next_mX as Long, next_mY as Long<br><br> Dim strHit As String<br> Dim theMouseResponseData As MouseResponseData<br><br> Do until (strHit = "leftbutton" or strHit = "rightbutton") <span style="color:rgb(7,55,99)"> </span><font style="color:rgb(7,55,99)" color="#ff0000"><=
this line seems superfluous to me; in the next line (.count > 0) it
is determined wheter a click is made, so there is no point in
determining it also in the previous line, moreover, strhit does not yet
have a value (was created only two lines above) and will also never get
the value of the button that was clicked with and lastly a do until loop
in this script is not needed. </font><br style="color:rgb(11,83,148)"><span style="color:rgb(0,0,0)"> 'Was there a response?</span><br> If Slide5.InputMasks.Responses.<div>Count > 0 Then<br><div><br> 'Get the mouse response<br> Set theMouseResponseData = CMouseResponseData(Slide5.<wbr>InputMasks.Responses(1))<br><br> 'Determine string name of Slide or SlideText object at<br> 'mouse click coordinates. Assign that value to strHit<br> strHit = theState.HitTest(<wbr>theMouseResponseData.CursorX,<wbr>theMouseResponseData.CursorY)<br><br> 'Compare string name where mouse click occurred to CorrectAnswer<br> 'attribute on each trial, and score response<br> 'NOTE: This comparison is case sensitive<br> If strHit = "leftbutton" or strHit = "rightbutton" Then<br> GoTo begingame<br><br> End if <span style="color:rgb(7,55,99)"><^=
with this IF THEN loop you tell the program to goto a label (I suppose?
begingame?) IF strhit contains the value of either of your response
buttons - but strhit will never holds that value, in the strHit= line
four lines above it is given the value of <i>the name of the subobject that the
mouseclick was made on</i> (I.e. textbox1 or image1 or whatever name you
defined for this subobject). StrHit will remain empty ("") if the click
was made anywhere else than on any subobject on the slide. </span><br style="color:rgb(11,83,148)"><br> Do Until (strHit = "leftbutton" or strHit = "rightbutton") <span style="color:rgb(153,0,255)"></span><br> ' capture & process further mouse clicks:<br> If (Mouse.Buttons And ebMouseButton1) Then<br> <wbr> Mouse.GetCursorPos next_mX, next_mY<br> <wbr> strHit = theState.HitTest( next_mX, next_mY )<br> End If<br><br> If strHit = "leftbutton" or strHit = "rightbutton" Then<br> GoTo begingame<br> End If<br><br> Loop <span style="color:rgb(7,55,99)"><^= similar to previous do until loop, this one is not useful and I actually do not quite understand what it does :s <br><br>So... I think this more original code (which a slight addition) should actually work for your purpose:<br></span></div><br> <span style="color:rgb(19,79,92)">Set theState = Slide5.States("Default")
</span><br style="color:rgb(19,79,92)">
<br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> 'Was there a response?
</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> If Slide5.InputMasks.Responses.</span><span style="color:rgb(19,79,92)">Co<wbr>unt > 0 Then
</span><br style="color:rgb(19,79,92)"><div>
<br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> 'Get the mouse response
</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> Set theMouseResponseData =
CMouseResponseData(Slide5.</span><span style="color:rgb(19,79,92)">Inpu<wbr>tMasks.Responses(1))
</span><br style="color:rgb(19,79,92)">
<br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> 'Determine string name of SlideImage or SlideText object at
</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> 'mouse click coordinates. Assign that value to strHit
</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> strHit = theState.HitTest(</span><span style="color:rgb(19,79,92)">theMouseRespo<wbr>nseData.CursorX,
theMouseResponseData.CursorY)
</span><br style="color:rgb(19,79,92)">
<br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> 'if strhit is empty (""), which is the case when the click was made outside an slide subobject, the</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> ' program is redirected to 'begingame' which is a label preceding the slide, so it will run again.</span><br style="color:rgb(19,79,92)"> <span style="color:rgb(19,79,92)"> ' if strhit has any other value (i.e. the name of a subject that was clicked on), this value is logged under "response"</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> <br> If strHit = ("") Then
</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> Goto begingame</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> Else
</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> c.SetAttrib "response", strHit
</span><br style="color:rgb(19,79,92)"><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> End if</span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> </span><br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> Else
</span><br style="color:rgb(19,79,92)">
<br style="color:rgb(19,79,92)"><span style="color:rgb(19,79,92)"> End If
</span><br style="color:rgb(19,79,92)">
<br></div><br style="color:rgb(7,55,99)"><span style="color:rgb(7,55,99)">Place this code in an inline following your slide.
On the slide itself give names to each of the two subobjects that can
be clicked on (or you can keep them with their generic names - but make sure you can afterwards figure out which object the response was made to). The above code does not compare or log the given answer to a 'correctanswer' but I gathered from your code that that is not needed - correct? If there are more subjects on your slide that just the two stimulus objects (i.e. a textbox giving directions?) than adjust the code so that a click on the non-stimulus subobject also leads to 'goto begingame'. <br style="color:rgb(7,55,99)"></span></div><br style="color:rgb(7,55,99)"><br style="color:rgb(7,55,99)"><span style="color:rgb(7,55,99)">Best,</span><br style="color:rgb(7,55,99)"><br style="color:rgb(7,55,99)"><br style="color:rgb(7,55,99)"><span style="color:rgb(7,55,99)">liw</span><br><br>On Sunday, 15 July 2012 08:04:05 UTC+2, David Wang wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><p style="text-align:center;clear:both"><a style="margin-left:1em;margin-right:1em" href="https://lh3.googleusercontent.com/-AOA1B2sdj6g/UAJdRKd8hAI/AAAAAAAAAD4/4CPkYnpqzd8/s1600/error.jpg" target="_blank"><img border="0" height="171" width="320"></a></p>This is the error screen I get when I try to generate script.<br></blockquote></blockquote>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups "E-Prime" group.<br />
To view this discussion on the web visit <a href="https://groups.google.com/d/msg/e-prime/-/vpI1Iduf-QIJ">https://groups.google.com/d/msg/e-prime/-/vpI1Iduf-QIJ</a>.<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 />
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.<br />