changing border color of a slide image after clicking on it

haslinger.hans11 at gmail.com haslinger.hans11 at gmail.com
Mon Oct 21 10:00:15 UTC 2013


Hallo David
 
Thank you for your endless patience and all your advice.
 
The solution with  a Do While... Loop seems to be a good one. 
I always tried to manage it the other way round.
 
 

> Use your imagination, be creative, explore, 
> that's what I would do.  And then please write back with what you 
> discover. 
>
 
I tried to heed that advice and played around with Sleep (I could not part 
with that approach).
I figured out following code: (I don't know if it is helpful when i color 
the code for better legibility)
 
 
Dim hitObject As SlideImage
Set hitObject = 
CSlideImage(ExternalCausesSlide.States("Default").Objects(strHit))       
  hitObject.BorderColor = CColor("cyan")
        hitObject.Draw 
 
  Dim RemainingSoundDuration as integer
       RemainingSoundDuration = c.GetAttrib("SoundDuration") - 
ExternalCausesSlide.RT 
        Sleep RemainingSoundDuration 
 
 
     hitObject.BorderColor = CColor("black")
     hitObject.Draw
End if
 
and it works perfectly. 
I've only tried it with some test sound files so far, because the final 
sound files aren't recorded yet. 
I have to check that later with the real sound files. But so far it is 
looking good.
 
 
So once again thank ypu for all your advice and patience, David.
Maybe I am going to drop in once again if any other problems occur.
 
 
Best regards 
Hans
 
 
 
 
 

Am Freitag, 18. Oktober 2013 19:23:10 UTC+2 schrieb McFarlane, David:

> Hans, 
>
> I have never used SoundBuffer myself, so you are the pioneer 
> here.  You should make up some simple demo program to use in testing 
> out your use of SoundBuffer outside of your specific experiment, and 
> try out some things.  Use your imagination, be creative, explore, 
> that's what I would do.  And then please write back with what you 
> discover. 
>
> As for the Sleep, I do feel that is the wrong way to go.  You cannot 
> stop a Sleep.  Get rid of the Sleep.  From what I understand of your 
> task, you just want to run some loop until the sound is done playing, 
> and then just move on to the rest of your program.  Something roughly like 
>
>      Do While (mySoundBuffer.Status = ebBufferStatusPlaying) 
>          ' loop empty on purpose 
>      Loop 
>      ' sound done playing, proceed with next part of program... 
>
> or, maybe 
>
>      Do Until (mySoundBuffer.Status = ebBufferStatusStopped) 
>          ' loop empty on purpose 
>      Loop 
>      ' sound done playing, proceed to next part of program... 
>
> you will have to think about this and play around some.  This all 
> assumes that SoundBuffer.Status works as we expect it to, so you just 
> have to explore.  And remember, you can also go straight to PST 
> Support to get help from the ultimate experts. 
>
> Regards, 
> -- David McFarlane 
>
>
> At 10/18/2013 05:15 AM Friday, haslinge... at gmail.com <javascript:> wrote: 
> >Hallo again David 
> > 
> >I just want to be sure if the code: 
> > 
> >Dim ExternalCausesSound As SlideSoundOut 
> >          Set ExternalCausesSound = 
> > 
> CSlideSoundOut(ExternalCausesSlide.States("Default").Objects("ExternalCausesSound")) 
>
> > (ExternalCausesSound is the Name of my SlideSound) 
> > 
> >Dim NewBuffer As SoundBuffer 
> >        Set NewBuffer = ExternalCausesSound.Buffers(1) 
> > 
> >...leads to the correct Sound Buffer before I try something with 
> >SoundBuffer.Status. 
> > 
> > 
> >At the Moment I am playing around with: 
> > 
> >Select Case NewBuffer.Status 
> >      Case ebBufferStatusStopped 
> >          ... (some code that stops the "Sleep" or leads to the next 
> > Slide State) 
> > 
> > 
> >I just want to know if I am on the right way or about to get lost 
> completely. 
> > 
> >Best regards 
> >Hans 
> > 
> > 
> > 
> >Am Donnerstag, 17. Oktober 2013 17:41:34 UTC+2 schrieb McFarlane, David: 
> >Hans, 
> > 
> >I'm afraid you have lost me again.  But now you should have all the 
> >pieces you need in order to do what you want, and you should be able 
> >to puzzle it out yourself from here. 
> > 
> >Best, 
> >-- David McFarlane 
> > 
> > 
> >At 10/17/2013 06:29 AM Thursday, haslinge... at gmail.com wrote: 
> > >Hallo David 
> > > 
> > >Thank you for the advice with SoundBuffer.Status. 
> > > 
> > > 
> > >Now here is my restatement of your specifications: 
> > >- E-Prime simultaneously presents a visual stimulus (containing a 
> number 
> > >of target areas) and starts playing a sound. 
> > >- The visual stimulus remains until, and only until, the sound the 
> > >finishes playing. 
> > >- The subject uses the mouse to respond by clicking target areas on the 
> > >display, and when the subject clicks on a target area, the border of 
> > >that area changes Color 
> > > 
> > > 
> > >Yes, that is correct. 
> > > 
> > > 
> > >I've tried to create a code with SoundBuffer.Status. But I am not 
> > >sure if it is correct that way: 
> > > 
> > > 
> > >Dim ExternalCausesSound As SlideSoundOut 
> > >          Set ExternalCausesSound = 
> > > 
> > 
> CSlideSoundOut(ExternalCausesSlide.States("Default").Objects("ExternalCausesSound")) 
>
> > 
> > > 
> > > 
> > >Dim NewBuffer As SoundBuffer 
> > >        Set NewBuffer = ExternalCausesSound.Buffers(1) 
> > > 
> > > 
> > >Then i would try something like: 
> > > 
> > >If NewBuffer.Status = 0   Then   ..... 
> > > 
> > >,so if the Buffer.Status is "Stopped", the Sleep Timer would be 
> > >stopped or the current SlideState would skip to the following State. 
> > >(I've set the Sleep to something longer then the Duration of the Sound) 
> > >So basically I would need a command which I could insert after 
> > >"Then" to stop the Sleep time. 
> > > 
> > >Could I use  "hitObject.Clear"  for that? 
> > > 
> > > 
> > >Best regards 
> > >Hans 
> > > 
> > > 
> > > 
> > >I 
> > > 
> > > 
> > >Am Mittwoch, 16. Oktober 2013 18:31:11 UTC+2 schrieb McFarlane, David: 
> > >Hans, 
> > > 
> > >Ah, there's the confusion -- you referred to "SoundOut" when you meant 
> > >"SlideSound".  SoundOut and SlideSound share a lot of properties, but 
> > >they are two different things that are used in different ways.  You do 
> > >not have a SoundOut in your Procedure, just a SlideSound as a 
> sub-object 
> > >of your Slide. 
> > > 
> > >Now here is my restatement of your specifications: 
> > >- E-Prime simultaneously presents a visual stimulus (containing a 
> number 
> > >of target areas) and starts playing a sound. 
> > >- The visual stimulus remains until, and only until, the sound the 
> > >finishes playing. 
> > >- The subject uses the mouse to respond by clicking target areas on the 
> > >display, and when the subject clicks on a target area, the border of 
> > >that area changes color. 
> > > 
> > >Now you are just stuck accomplishing that second objective.  For that, 
> I 
> > >think you need to use SoundBuffer.Status -- see that topic in the 
> > >E-Basic Help facility.  You will also have to get access to the 
> > >SoundBuffer object that plays your sound -- for that, just browse the 
> > >related topics in the E-Basic Help facility, and/or look at 
> > >sound-related code generated for you by E-Studio (that's how I figure 
> > >all this stuff out, if I can do that then so can you :) ).  And of 
> > >course, you may also always contact PST Support for help, see below. 
> > > 
> > >Best, 
> > >----- 
> > >David McFarlane 
> > >E-Prime training online: 
> > ><<http://psychology.msu.edu/Workshops_Courses/eprime.aspx>http://ps 
> > ychology.msu.edu/Workshops_Courses/eprime.aspx>
> http://psychology.msu.edu/Workshops_Courses/eprime.aspx 
> > 
> > > 
> > >Twitter:  @EPrimeMaster 
> > >(<<http://twitter.com/EPrimeMaster>http://twitter.com/EPrimeMaster> 
> > <http://twitter.com/EPrimeMaster>twitter.com/EPrimeMaster) 
> > > 
> > >/----------- 
> > >Stock reminder:  1) I do not work for PST.  2) PST's trained staff take 
> > >any and all questions at 
> > ><<http://support.pstnet.com/e%2Dprime/support/login.asp>http://supp 
> > ort.pstnet.com/e%2Dprime/support/login.asp>
> http://support.pstnet.com/e%2Dprime/support/login.asp 
> > 
> > >, and they strive 
> > >to respond to all requests in 24-48 hours -- this is pretty much their 
> > >substitute for proper documentation, so make full use of it.  3) In 
> > >addition, PST takes questions at their Facebook page 
> > >(<<http://www.facebook.com/pages/Psychology-Software-Tools-Inc/2418 
> > 02160683>
> http://www.facebook.com/pages/Psychology-Software-Tools-Inc/241802160683>
> http://www.facebook.com/pages/Psychology-Software-Tools-Inc/241802160683 
> > 
> > > 
> > >), and offers several instructional videos there and on their YouTube 
> > >channel 
> > >(<<http://www.youtube.com/user/PSTNET>http://www.youtube.com/user/P 
> > STNET>http://www.youtube.com/user/PSTNET 
> > >) (no Twitter feed yet, 
> > >though).  4) If you do get an answer from PST staff, please extend the 
> > >courtesy of posting their reply back here for the sake of others. 
> > >\----------- 
> > > 
> > > 
> > >haslinge... at gmail.com wrote: 
> > > > Hallo David 
> > > > 
> > > > Thank you for your help. 
> > > > 
> > > > 
> > > >     At this point I would need you to draw 
> > > > 
> > > >     out a very clear diagram of your Procedure structure, along 
> > > >     with clear specifications of what you want it to do 
> > > > 
> > > > 
> > > > The Procedure looks  like this: 
> > > > 
> > > > 
> > > > ... 
> > > > ... 
> > > > 
> > > > ExternalCausesProc 
> > > >       ExternalCausesList 
> > > >            ExternalCausesTrialProc 
> > > >                Instruction (TextBox) 
> > > >                restart2 (Label) 
> > > >                ExternalCausesSlide (Slide) 
> > > >                InLine2 (InLineCode) 
> > > > ... 
> > > > ... 
> > > > 
> > > > 
> > > > After a short Instruction, there is an Image presented on the 
> > > > ExternalCausesSlide as a Stimulus (e.g. child is getting a birthday 
> > > > present). 
> > > > There is also a SoundOut on the ExternalCausesSlide which describes 
> the 
> > > > scene in the Image. 
> > > > Additionaly there are 4 smaller Images as possible answers for the 
> > > > Stimulus Image. 
> > > > I've made an attribute for every Image and the SoundOut in my 
> > > > ExternalCausesList. 
> > > > 
> > > > Subjects should have time to click on one of the 4 target Images 
> until 
> > > > the SoundOut was played completely. 
> > > > I want to highlight the Image a subject chooses by changing the 
> border 
> > > > color of that Image to "cyan" (black is my default border color) so 
> the 
> > > > subject knows that its answer was registered and it can change the 
> > > > current answer (this is another thing i could need some help with). 
> > > > 
> > > > I tried to implement the following code (which i've found somewhere 
> in 
> > > > this google group) for changing the border color to "cyan" and back 
> to 
> > > > "black" (default setting) before a new Stimulus is presented: 
> > > > 
> > > > Dim hitObject As SlideImage 
> > > >    Set hitObject = 
> > > > CSlideImage(ExternalCausesSlide.States("Default").Objects(strHit)) 
> > > > 
> > > >             hitObject.BorderColor = CColor("cyan") 
> > > >             hitObject.Draw 
> > > >             Sleep 5000 
> > > > 
> > > >       hitObject.BorderColor = CColor("black") 
> > > > 
> > > > 
> > > > 
> > > > The current slide should be terminated after the Sound is played so 
> I've 
> > > > set  "End Sound Action" to "Terminate"    and "End Action" (in the 
> > > > ExternalCausesSlide Properties) to "none". 
> > > > Now the color changed to "cyan" after the Sound was played  and not 
> > > > immediately after the click. 
> > > > 
> > > > So i've changed the Settings to "End Action" -> "Terminate" and 
> > > > "EndSoundAction" -> "Terminate". 
> > > > Now the color changed immediately after the click occured and 
> remained 
> > > > "Cyan" for 5sec before changing back to "black". 
> > > > But if the click occured at the end of the SoundOut with less than 
> 5sec 
> > > > remaining, there was an interference with the Sound of the following 
> > > > Stimulus. 
> > > > 
> > > > Then I've tried "End Action" -> "Terminate" and "End Sound Action" 
> -> 
> > > > "none". 
> > > > Now the Color changes immediately after the click and remains for 
> the 5 
> > > > sec no matter if the Sound is completely played or not. 
> > > > But if no click occurs, there is no termination. 
> > > > 
> > > > 
> > > > Now I thought I could use the "Terminate/Terminate"-setting  and a 
> Sleep 
> > > > time which is equal to the remaining duration of the sound file 
> after 
> > > > the click occured, (something like  Sleep "Duration Sound - RT (Time 
> > > > until click?)). 
> > > > This way, the slide would terminate after the click + Sleep time or 
> if 
> > > > the sound file was played completely (if there was no click). 
> > > > There would also not be any interference with the following Sound 
> file, 
> > > > because the Sleep time is never longer than the Sound file itself. 
> > > > 
> > > > 
> > > > 
> > > > 
> > > >     That said, first, you do not understand your code correctly.  As 
> > > >     written, it means the color of the image, which was clicked, 
> changes 
> > > >     to "cyan" and would later change to "black" at whatever time 
> your 
> > > >     hitObject gets redrawn, and goodness knows when that will 
> happen. 
> > > > 
> > > > 
> > > > 
> > > > Actually, it changes back to "black". 
> > > > But maybe that is just because "black" ist my default border color 
> and 
> > > > the settings are just reset to the default settings after Sleep. 
> > > > 
> > > > 
> > > > 
> > > >     As a general strategy, I prefer to do as much as possible 
> > through the 
> > > >     program structure & object properties, and to leave less to 
> > > inline code. 
> > > > 
> > > > 
> > > > 
> > > > Actually this was the prefered strategy for my project and it worked 
> > > > fine except for strHitTest for collecting Mouse Responses and 
> logging 
> > > > the correct answer. 
> > > > Basically my program is completed, but i would like to add some 
> little 
> > > > improvements, like this highlighting thing, to make it look better 
> > > > 
> > > > I hope my remarks are not too confusing. 
> > > > 
> > > > 
> > > > Best regards 
> > > > Hans 
> > > > 
> > > > 
> > > > 
> > > > Am Dienstag, 15. Oktober 2013 16:37:46 UTC+2 schrieb McFarlane, 
> David: 
> > > > 
> > > >     Hans, 
> > > > 
> > > >     I am afraid that I do not quite follow all of this.  You refer 
> to a 
> > > >     Slide, a SoundOut, and an Inline, and I do not know how they all 
> > > >     interrelate (in particular, I do not recall the complication of 
> a 
> > > >     SoundOut in your first post).  At this point I would need 
> > you to draw 
> > > >     out a very clear diagram of your Procedure structure, along with 
> > > >     clear specifications of what you want it to do. 
> > > > 
> > > >     That said, first, you do not understand your code correctly.  As 
> > > >     written, it means the color of the image, which was clicked, 
> changes 
> > > >     to "cyan" and would later change to "black" at whatever time 
> your 
> > > >     hitObject gets redrawn, and goodness knows when that will 
> > happen.  If 
> > > >     you want your inline code to make the BorderColor black, then 
> you 
> > > >     must also follow that line with another hitObject.Draw 
> > command, which 
> > > >     is missing from your code without comment.  If you left that out 
> on 
> > > >     purpose (e.g., because the redraw will be taken care of by a 
> later 
> > > >     object), then you must add a comment to your code to explain 
> that. 
> > > > 
> > > >     As far as settting the Sleep time to something like "remaining 
> time 
> > > >     of SoundOut", I suppose you might use some combination of 
> > Clock.Read, 
> > > >     SoundOut.TargetOffsetTime, and GetNextTargetOnsetTime, but I 
> think 
> > > >     that a sloppy way to do things.  I would generally rather let 
> the 
> > > >     SoundOut handle the timing, and then follow that with more 
> inline 
> > > >     code to do whatever needs doing.  Again, we need a better look 
> at 
> > > >     your Procedure structure, you may need to revise it. 
> > > > 
> > > >     As a general strategy, I prefer to do as much as possible 
> > through the 
> > > >     program structure & object properties, and to leave less to 
> inline 
> > > >     code. 
> > > > 
> > > >     Regards, 
> > > >     -- David McFarlane 
> > > > 
> > > > 
> > > >     At 10/15/2013 04:56 AM Tuesday, haslinge... at gmail.com<javascript:> 
> > > >     wrote: 
> > > >      >Hallo David 
> > > >      > 
> > > >      > 
> > > >      >I've tried another code for the changing border color part: 
> > > >      > 
> > > >      >Dim hitObject As SlideImage 
> > > >      >Set hitObject = 
> > > >     
>  >CSlideImage(ExternalCausesSlide.States("Default").Objects(strHit)) 
> > > >      >   hitObject.BorderColor = CColor("cyan") 
> > > >      >         hitObject.Draw 
> > > >      >         Sleep 5000 
> > > >      >   hitObject.BorderColor = CColor("black") 
> > > >      > 
> > > >      > 
> > > >      >If I understood this code right, that means the color of the 
> > > >      >image,which was clicked, changes to "cyan "and after 5 sec it 
> > > >      >changes back to "black". 
> > > >      > 
> > > >      >But now I have some problems timing the change of color and 
> the 
> > > >     sound file. 
> > > >      > 
> > > >      >At first I set "End Action" in the Slide Properties to 
> > "(none)" and 
> > > >      >"End Sound Action" in the Slide Sound Out Properties to 
> > "Terminate". 
> > > >      >Then the color was only changing after the soundfile was over. 
> > > >      > 
> > > >      >Then I changed the settings to "End Action" -> Terminate and 
> added 
> > > >      >"Sleep 5000" in the inline code. 
> > > >      >Now the color changes immediately after clicking and stays for 
> the 
> > > >      >5sec before changing back to black 
> > > >      >But if the Sleep Time after clicking is longer then the 
> remaining 
> > > >      >time of the SoundOut, the SoundOut of the next Slide State 
> isn't 
> > > >     starting. 
> > > >      > 
> > > >      >Is there any command which sets the Sleep time to something 
> like 
> > > >      >"remaining time of SoundOut"? 
> > > >      > 
> > > >      > 
> > > >      >Best regards 
> > > >      >Hans 
> > > 
> > >-- 
> > >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+u... at googlegroups.com. 
> > >To post to this group, send email to e-p... at googlegroups.com. 
> > >To view this discussion on the web visit 
> > ><<https://groups.google.com/d/msgid/e-prime/af93d00c-d985-43d7-897b 
> > -433e8d5f994f%40googlegroups.com>
> https://groups.google.com/d/msgid/e-prime/af93d00c-d985-43d7-897b-433e8d5f994f%40googlegroups.com
> >
> https://groups.google.com/d/msgid/e-prime/af93d00c-d985-43d7-897b-433e8d5f994f%40googlegroups.com. 
>
> > 
> > >For more options, visit 
> > ><<https://groups.google.com/groups/opt_out>https://groups.google.co 
> > m/groups/opt_out>https://groups.google.com/groups/opt_out. 
> > 
> >-- 
> >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+u... at googlegroups.com <javascript:>. 
> >To post to this group, send email to e-p... at googlegroups.com<javascript:>. 
>
> >To view this discussion on the web visit 
> ><
> https://groups.google.com/d/msgid/e-prime/c59eade2-a635-4e48-8b07-f4e272f8222c%40googlegroups.com
> >
> https://groups.google.com/d/msgid/e-prime/c59eade2-a635-4e48-8b07-f4e272f8222c%40googlegroups.com. 
>
> >For more options, visit 
> ><https://groups.google.com/groups/opt_out>
> https://groups.google.com/groups/opt_out. 
>
>

-- 
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/c5bf5751-04c2-4b06-a2c8-4e7142d55d3e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20131021/af34a6f0/attachment.htm>


More information about the Eprime mailing list