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

Anne-Wil liwenna at gmail.com
Sun Jul 15 12:34:32 UTC 2012


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 shoudl be either placed on a 
single line or closed with and END IF  statement and similarly for 
conditional statements like the DO WHILE loop etc. The error occurs because 
there is an END statement misplaced or missing, cause the program to get 
'lost'. 

As for your 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.

Neither of these 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?). 

'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 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 a 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 subobjct, the
                ' program is redirected to 'begingame' which is a label 
preceding the slide.

               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 and also (if 
needed?) create an attribute in your list called CorrectAnswer, for which 
each cell holds the name of the subject that is the correct answer in that 
trial (if there is no correct anwer the lines from "If strhit =" to the 
next "End IF" can be removed. 


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/-/F5-FlLXgFoUJ.
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/7c1588eb/attachment.htm>


More information about the Eprime mailing list