If you go this route (which is probably how I would do it), depending
on how the PsychLab equipment works you might also need to send a
full "pulse" and reset the output before continuing, something like
WritePort &H378, Asc(Proposal1.RESP)
Sleep 20
WritePort &H378, 0
Oh, following my fussy habits I would also replace the "magic number"
&H378 with a proper constant, e.g.,
Const LptDataPort as Integer = &H378
WritePort LptDataPort, Asc(Proposal1.RESP)
Sleep 20
WritePort LptDataPort, 0
-- David McFarlane, Professional Faultfinder
> I changed the content of the Inline and now I only have one Inline
> after the Proposal with the following:
>
> If Proposal.RESP = "a" then WritePort &H378, Asc(Proposal.Resp) else
> if Proposal.RESP = "r" then WritePort &H378, Asc(Proposal.Resp) else
> WritePort &H378, 255
>
> Sleep 20
> WritePort &H378, 0
>
> Is this what you're suggesting?
Good job! If you have this working then you do not need to change a
thing. But I will add a short programming lesson.
Your script above has a bit of redundancy. Here is a way to write it
without the redundancy (and using constants to get rid of the "magic
numbers", which I believe improves readability, and adding a few
comments for clarity):
Const LptDataPort as Integer = &H378 ' or 888 decimal
Const NoResponseEvent as Integer = &HFF ' or 255 decimal
Const EventPulseDuration_ms as Integer = 20
' Send appropriate event pulse to PsychLab equipment...
If Proposal.RESP <> "" Then ' got a response
WritePort LptDataPort, Asc(Proposal.Resp)
Else ' no response
WritePort LptDataPort, NoResponseEvent
End If
Sleep EventPulseDuration_ms
WritePort LptDataPort, 0
BTW, you can also test for a response by using
If Proposal.RT <> 0
as well as other tests that I have documented elsewhere. It is largely
a matter of personal taste (I like the test against 0, since it seems
more efficient to test the value of an integer rather than a full string).
Const LptDataPort as Integer = &H378 ' or 888 decimal
Const NoResponseEvent as Integer = &HFF ' or 255 decimal
Const EventPulseDuration_ms as Integer = 20
' Send appropriate event pulse to PsychLab equipment...
WritePort LptDataPort, Iif( (Proposal.RT = 0), NoResponseEvent,
Asc(Proposal.Resp) )
Sleep EventPulseDuration_ms
Const LptDataPort as Integer = &H378 ' or 888 decimal
Const NoResponseEvent as Integer = &HFF ' or 255 decimal
Const EventPulseDuration_ms as Integer = 20
' Send appropriate event pulse to PsychLab equipment...
WritePort LptDataPort, Iif( Proposal.RT, Asc(Proposal.Resp),
NoResponseEvent )
Sleep EventPulseDuration_ms