'/----------------------------------------------------------------------
' We wish to present a stimulus (in this case, StimText), get a
' response during that stimlus, and raise a signal as soon as the
' subject responds.
'
' To do that, we need to run this inline code during StimText.  We
' could simply set the Duration of StimText to 0 or so (depending on
' considerations such as leaving some time between stimulus .OnsetSignal
' and .OffsetSignal) and then our code would have to also handle
' further stimulus timing.  But with judicious use of Duration and
' PreRelease, E-Prime will automatically take care of stimulus timing
' for us.
'
' So instead we simply set the Duration of StimText as desired (which
' as a result automatically determines the target onset time for the
' next stimulus object), and we set the PreRelease of StimText to a
' suitably large value (preferably >= Duration, but perhaps less due
' to other considerations as mentioned earlier).  Now this code will
' start to run soon after the onset of StimText, and handle the
' reaction to the subject response.
'
' Finally, this code simply makes use of .IsPending() to detect the
' response (see the InputMask.IsPending topic in the online E-Basic
' Help).  Note that as a result StimText will last at least as long
' its input mask Time Limit, regardless of its Duration (if you just
' keep Time Limit at the default of "(same as duration)" then this
' will not pose a problem).
Const  LptDataPort as Integer = &H0378  ' adjust this for your system
Const  SignalData as Integer = &HFF  ' adjust this for your device
Const  LoopDelay as Long = 2  'ms; set as small as possible for your
         ' system
Do While StimText.InputMasks.IsPending()
         ' Some slower machines (such as my home laptop) need a delay so that
         ' EP can detect & handle input:
         Sleep LoopDelay
Loop
WritePort LptDataPort, SignalData
'\----------------------------------------------------------------------
This is fine as long as you limit the response to coming during the 
stimulus.  If you want to present a train of stimuli during the 
response period then you must do a little more.  I also have a 
solution for that, but it is rather intricate and too much trouble to 
go into here, so I hope this is good enough for now.
-- David McFarlane, Professional Faultfinder
-- David McFarlane, Professional Faultfinder
>Dear Professional Faultfinder,
>
>Thanks for posting your script!
>In my experiment the response comes after the offset of the target
>stimulus.
>If it is not too much of a trouble, I would appreciate to hear about
>your
>solution to presenting other stimuli during the response period.
>
>Thanks again!
>
>
More likely the questioner had a simpler case in mind, i.e., a 
self-paced stimulus where the response terminates the stimulus, and 
then E-Prime sends an output signal.  For that simpler case, please 
see discussion at 
http://groups.google.com/group/e-prime/browse_thread/thread/ef0e5a8d8b87aa0c .
-- David McFarlane, Professional Faultfinder
- Set the response Time Limit of the stimlus (e.g., StimText) to 
match how long you want to allow for a response (i.e., use "extended 
input" (see Appendix C of the E-Prime User's Guide)).  (This is 
implied in one of the later comments in the code excerpt, but is 
worth making more explicit.)
- If you want to allow the stimulus to complete its Duration after a 
receiving a response, then set the End Action of its input masks to (none).
Also, I now notice that the comment "... StimText will last at least 
as long its input mask Time Limit" is not quite correct, but at the 
moment I don't know quite how to accurately express the resulting 
interactions between Duration, Time Limit, End Action, and response, 
so I will leave that as an exercise for others.
Hope that helps,
-- David McFarlane, Professional Faultfinder