parallel port communication: event markers
David McFarlane
mcfarla9 at msu.edu
Fri Jul 3 15:20:02 UTC 2009
Sofia,
> 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).
-- David McFarlane, Professional Faultfinder
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "E-Prime" group.
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
-~----------~----~----~----~------~----~------~--~---
More information about the Eprime
mailing list