How to display a selected response (selected by press a key in the keyboard)

Oli Chen yhattaque at gmail.com
Fri Sep 5 02:40:19 UTC 2014


Thank you very much, David! :)
It is very nice of you to give such a quick reply!

I understood what you mentioned, and tried to edit the code as you
suggested.
However, there is still the error :(  and it came from the same line:  Set
hitObject = theState.Objects("Text1")
the error message is "assignment variables and expression are different
types"...

I then wandered whether it is because I made some mistake in editing my
slide.
I had a slide with three slideTexts. I added "keyboard" as the device for
response, and the allowance is "2", "3", and "4".
the end action is set as "terminate", but i also tried with "none".

I have no idea which part can be wrong...
do you have any other suggestion or solution?

thanks a lot again!!!
have a good day!!^______^
oli:)


On Fri, Sep 5, 2014 at 3:41 AM, David McFarlane <mcfarla9 at msu.edu> wrote:

> You did not say what line caused the error message, but I suspect it came
> up for one of the "hitObject = ..." lines.  That error message, "object
> does not have an assignable default property", typically comes up when you
> forget to put "Set" in front of the assignment statement for an object
> variable (obviously -- NOT!).  In E-Basic/VBA, you must use Set at the
> start of any assigment statement for an object variable, and you must *not*
> use Set at the start of any assignment statement for ordinary varibles (you
> may in this case preface the assigment with the arcane "Let" keyword,
> otherwise that is implied).  (Yes, this is an absurd rule, peculiar to VBA,
> and provides many headaches with no compensating advantages.)
>
> So your hitObject assigment statements should read like
>
>     Set hitObject = theState.Objects("Text1")
>
> Also note that for cases "3" & "4" you switch to using ResponseSlide.Name,
> which I think will not work.
>
> That said ...  What happens if RESP is not 2, 3, or 4?  Of course, your
> input mask Allowable may guarantee valid RESP values, but safe programming
> practice dictates that your code not fail in the event of unexpected
> inputs.  As it stands, this code would throw a runtime error because
> hitObject would not be assigned before it reaches the hitObject.BackColor
> statement.  With that in mind, your code might work out to something like
>
>     Dim theState As SlideState
>     Dim hitObject As SlideText
>
>     Set theState = ResponseSlide.States(ResponseSlide.ActiveState)
>     Select Case ResponseSlide.RESP
>     Case "2"
>         Set hitObject = theState.Objects("Text1")
>     Case "3"
>         Set hitObject = theState.Objects("Text2")
>     Case "4"
>         Set hitObject = theState.Objects("Text3")
>     End Select
>     If Not(hitObject Is Nothing) Then
>         hitObject.BackColor = CColor("green")
>         hitObject.Draw
>     Else  ' sanity check
>         ' code for invalid response here
>     End If
>
> If you could judiciously rename your objects so that they directly
> reflected the response value, you could compact this even further, e.g.,
>
>     Dim theState As SlideState
>     Dim hitObject As SlideText
>
>     Set theState = ResponseSlide.States(ResponseSlide.ActiveState)
>     Select Case ResponseSlide.RESP
>     Case "2", "3", "4"
>         Set hitObject = theState.Objects("Text" & ResponseSlide.RESP)
>         hitObject.BackColor = CColor("green")
>         hitObject.Draw
>     Case Else  ' sanity check
>         ' code for invalid response here
>     End Select
>
> Just some ideas, you can take it from there.
>
> -----
> 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) You may reach PST's trained
> staff (and other support facilities) at https://support.pstnet.com .  3)
> 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/4/2014 06:43 AM Thursday, Chen wrote:
>
>> I would like to highlight an object based on the subject's response.
>>
>> I learned from some codes when an object was selected by the subject with
>> a mouse
>>
>> ...unfortunately I am not smart enough to apply it in when I ask my
>> subject to give a response by pressing the key "2", "3", or "4".
>>
>>  Basically my subject has 3 seconds to make a choice.
>>
>> I would like the box surrounding the selected option to change color (to
>> green for example) while the slide is still displayed, or the words (in the
>> text of the slide) change color.
>>
>> My code is like this:
>>
>> Dim theState As SlideState    '
>>
>> Dim hitObject As SlideText
>>
>> Set theState = ResponseSlide.States(ResponseSlide.ActiveState)
>> 'ResponseSlide is the name of the slide'
>>
>> Select Case ResponseSlide.RESP
>>
>> Case "2"
>>
>>    hitObject = theState.Objects("Text1")
>>
>> Case "3"
>>
>>    hitObject = ResponseSlide.Name("Text2")
>>
>> Case "4"
>>
>>    hitObject = ResponseSlide.Name("Text3")
>>
>> End Select
>>
>> hitObject.BackColor = CColor("green")
>>
>> hitObject.Draw
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> the error message is like this:
>>
>> The object does not have an assignable default property.
>>
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Hope someone can help me...I have been stuck for an entire day...;-;
>>
>> Thanks a lot in advance!
>>
>> OLI:)
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "E-Prime" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to e-prime+unsubscribe at googlegroups.com.
> To post to this group, send email to e-prime at googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/e-prime/5408c098.1243320a.687a.0b18SMTPIN_
> ADDED_MISSING%40gmr-mx.google.com.
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Yin-Hua, Chen

Research Center for Mind, Brain and Learning
National Chengchi University
No. 64, Sec. 2, Zhi-Nan Rd., Wen-shan District, Taipei City 11605, Taiwan
Tel: +886 2 2234 4967

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/CANgqGTPA%2B0yVTMaDXcepv4%2BtekTHM_4nPeTZFGWdYJUdMctJ3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20140905/2fa08ac0/attachment.htm>


More information about the Eprime mailing list