need help with code, I am trying to have two clickable response buttons on a slide

David Wang jiaxiking at gmail.com
Sun Jul 15 20:49:00 UTC 2012



On Sunday, July 15, 2012 8:44:49 AM UTC-4, Anne-Wil wrote:
>
> Hi David,
>
>
> 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.
>
> 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'. 
>
> 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 :) ). 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?). 
>
> For 'educational purposes' I'll post some remarks with the code that you 
> posted and under that I'll post a new code suggestion. 
>
> 'Designate "theState" as the Default Slide State, which is the
>         'current, ActiveState on the Slide object "Stimulus"
>
>         Dim theState as SlideState
>         Set theState = Slide5.States("Default")
>
>         Dim next_mX as Long, next_mY as Long
>
>         Dim strHit As String
>         Dim theMouseResponseData As MouseResponseData
>
>         Do until (strHit = "leftbutton" or strHit = "rightbutton")   <= 
> 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. 
>         'Was there a response?
>                 If Slide5.InputMasks.Responses.
> Count > 0 Then
>
>                         'Get the mouse response
>                         Set theMouseResponseData = 
> CMouseResponseData(Slide5.InputMasks.Responses(1))
>
>                         'Determine string name of Slide or SlideText 
> object at
>                         'mouse click coordinates. Assign that value to 
> strHit
>                         strHit = 
> theState.HitTest(theMouseResponseData.CursorX,theMouseResponseData.CursorY)
>
>                         'Compare string name where mouse click occurred to 
> CorrectAnswer
>                         'attribute on each trial, and score response
>                         'NOTE: This comparison is case sensitive
>                         If strHit = "leftbutton" or strHit = "rightbutton" 
> Then
>                              GoTo begingame
>
>                         End if <^= 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 *the 
> name of the subobject that the mouseclick was made on* (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. 
>
>                 Do Until (strHit = "leftbutton" or strHit = "rightbutton") 
>                 ' capture & process further mouse clicks:
>                         If (Mouse.Buttons And ebMouseButton1) Then
>                                 Mouse.GetCursorPos next_mX, next_mY
>                                 strHit = theState.HitTest( next_mX, 
> next_mY )
>                         End If
>
>                         If strHit = "leftbutton" or strHit = "rightbutton" 
> Then
>                              GoTo begingame
>                         End If
>
>      Loop <^= similar to previous do until loop, this one is not useful 
> and I actually do not quite understand what it does :s 
>
> So... I think this more original code (which a slight addition) should 
> actually work for your purpose:
>
>       Set theState = Slide5.States("Default") 
>
>         'Was there a response? 
>         If Slide5.InputMasks.Responses.Count > 0 Then 
>
>                 'Get the mouse response 
>                 Set theMouseResponseData = CMouseResponseData(Slide5.InputMasks.Responses(1)) 
>
>
>                 'Determine string name of SlideImage or SlideText object 
> at 
>                 'mouse click coordinates. Assign that value to strHit 
>                 strHit = theState.HitTest(theMouseResponseData.CursorX, 
> theMouseResponseData.CursorY) 
>
>                 'if strhit is empty (""), which is the case when the click 
> was made outside an slide subobject, the
>                 ' program is redirected to 'begingame' which is a label 
> preceding the slide, so it will run again.
>                 ' if strhit has any other value (i.e. the name of a 
> subject that was clicked on), this value is logged under "response"
>             
>               If strHit = ("") Then 
>                       Goto begingame
>               Else 
>                        c.SetAttrib "response", strHit 
>
>                End if
>                
>         Else 
>
>         End If 
>
>
> 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'. 
>
>
> Best,
>
>
> liw
>
> On Sunday, 15 July 2012 08:04:05 UTC+2, David Wang wrote:
>>
>>
>> <https://lh3.googleusercontent.com/-AOA1B2sdj6g/UAJdRKd8hAI/AAAAAAAAAD4/4CPkYnpqzd8/s1600/error.jpg>
>> This is the error screen I get when I try to generate script.
>>
>

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To view this discussion on the web visit https://groups.google.com/d/msg/e-prime/-/vpI1Iduf-QIJ.
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 this group at http://groups.google.com/group/e-prime?hl=en.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20120715/f14991c9/attachment.htm>


More information about the Eprime mailing list