[WARNING]
WARNING: DO NOT EDIT THIS FILE DIRECTLY!
Use only E-Studio to edit this file.
Editing of this file from any other means is not supported
and may corrupt the experiment design specification.
Technical support will not be able to address any issue in
regards to this file format.

[Experiment]
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=94
_VersionPersist=6
Root="SessionProc"
Author="Psychology Software Tools, Inc."
Abstract="NOTE: This sample uses deprecated methods to configure a Parallel Port in E-Prime. This sample is provided for legacy purposes only. These methods should not be used when creating new experiments. Instead, PST recommends adding a ParallelPort device to an experiment via the Devices tab of the Experiment Object's property pages and setting its properties appropriately. See <kb>17150</kb> for more information.\r\n \r\nNOTE: Most Parallel Ports or PCI cards today support bi-directional communications and can detect which is needed automatically. E-Prime is capable of both sending and receiving markers through the Parallel Port, though not simultaneously. If you are using an older Parallel Port or PCI card, it may need to be configured specifically for input or output.\r\n \r\nAbstract\r\nThis sample investigates the ability for your computer to use ECP/EPP Parallel Ports to emulate legacy SPP or Bi-Directional modes. With the script routines included in this experiment, you can configure your Parallel Port so that the DATA port (pins 2-9) act as either input or output. Using these commands allows for ease of configuration among the widest range of computers and reduces the need to edit the system BIOS to configure parallel ports.\r\n \r\nBy default, E-Prime has traditionally worked the best with Parallel Ports that are in 'Output Only' or 'SPP' mode. In this legacy mode, the Parallel Port allows for eight bits of output on the DATA port (pins 2-9). 5 bits of data could be read from the Status port.\r\n \r\nMost Parallel Ports or PCI cards today are newer ECP/EPP Parallel Ports, which provide the ability to emulate the older SPP or Bi-Directional Parallel Ports. This allows for the ability to set the DATA port on the Parallel Ports for reading or writing (but not simultaneously).\r\n  \r\nTo use the routines in your experiment, first copy and paste the User script area from this experiment into your experiment. Then, copy the 'Const PORT_ADDRESS' line from the top of the 'GetPortInfo' InLine object and paste it into your experiment, changing the port address value if needed. Finally, call the appropriate routines to configure your parallel port."
Notes=""
Creation=1098979058

[Device0]
_VersionPersist=1
OpenDevice=1
Width=640
Height=480
Bpp=16
Name="Display"
Class="Display"

[Device1]
_VersionPersist=1
OpenDevice=0
Channels=2
Samples=22050
Bps=16
Name="Sound"
Class="Sound"

[Device2]
_VersionPersist=1
OpenDevice=1
CollectionMode=1
EmulateDeviceName=""
CapsLock=0
NumLock=1
Name="Keyboard"
Class="Keyboard"

[Device3]
_VersionPersist=1
OpenDevice=1
CollectionMode=1
EmulateDeviceName=""
OpenMode=0
ShowCursor=0
Name="Mouse"
Class="Mouse"

[Device4]
_VersionPersist=1
OpenDevice=1
CollectionMode=1
EmulateDeviceName=""
Address="&H378"
Size=8
Invert=0
Mask="-1"
Name="Port"
Class="Port"

[DataFile]
WarnBeforeOverwrite=1
WarnIfConvertFailed=1
RemoveERecoveryFile=0
ReceiveFeedbackDuringDataFileConversion=1
LogLevel(2).Name="Block"
LogLevel(3).Name="Trial"
LogLevel(4).Name="SubTrial"
LogLevel(5).Name="LogLevel5"
LogLevel(6).Name="LogLevel6"
LogLevel(7).Name="LogLevel7"
LogLevel(8).Name="LogLevel8"
LogLevel(9).Name="LogLevel9"
LogLevel(10).Name="LogLevel10"

[StartupInfo]
DisplaySummary=1
UseDefaults=0

[StartupInfo1]
Name="Subject"
Prompt="Please enter the Subject Number (1-32767, 0=No Data Logging):"
DataType=0
Enabled=1
PromptEnabled=1
Default="1"
Min=0
Max=32767
PrivateFlags=268435477
PrivateInfo=1

[StartupInfo2]
Name="Session"
Prompt="Please enter the Session Number (1-32767):"
DataType=0
Enabled=1
PromptEnabled=1
Default="1"
Min=1
Max=32767
PrivateFlags=268435477
PrivateInfo=1

[StartupInfo3]
Name="Group"
Prompt="Please enter Subject's Group (0-32767):"
DataType=0
Enabled=0
PromptEnabled=0
Default="1"
Min=0
Max=32767

[StartupInfo4]
Name="Name"
Prompt="Please enter Subject's Name:"
DataType=1
Enabled=0
PromptEnabled=0
Default=""
MaxLength=255

[StartupInfo5]
Name="Age"
Prompt="Please enter Subject's Age (0-150):"
DataType=0
Enabled=0
PromptEnabled=0
Default="0"
Min=0
Max=150

[StartupInfo6]
Name="Sex"
Prompt="Please enter Subject's Sex:"
DataType=2
Enabled=0
PromptEnabled=0
Default="male"
Choice(1).Value="male"
Choice(2).Value="female"

[StartupInfo7]
Name="Handedness"
Prompt="Enter Subject's Handedness:"
DataType=2
Enabled=0
PromptEnabled=0
Default="left"
Choice(1).Value="left"
Choice(2).Value="right"

[StartupInfo8]
Name="ResearcherID"
Prompt="Please enter Researcher's ID:"
DataType=0
Enabled=0
PromptEnabled=0
Default="1"
Min=0
Max=32767

[Object0]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
_ItemList="LookAtUserScript;GetPortInfo;PortInfo;CheckContinue;InputDisplay;OutputDisplay;ConfigureAndGo;ExampleCalls;GoodbyeLabel;Goodbye"
_VersionPersist=1
FlowLines(0).Count=10
FlowLines(0).FlowItem(0).Name="LookAtUserScript"
FlowLines(0).FlowItem(1).Name="GetPortInfo"
FlowLines(0).FlowItem(2).Name="PortInfo"
FlowLines(0).FlowItem(3).Name="CheckContinue"
FlowLines(0).FlowItem(4).Name="InputDisplay"
FlowLines(0).FlowItem(5).Name="OutputDisplay"
FlowLines(0).FlowItem(6).Name="ConfigureAndGo"
FlowLines(0).FlowItem(7).Name="ExampleCalls"
FlowLines(0).FlowItem(8).Name="GoodbyeLabel"
FlowLines(0).FlowItem(9).Name="Goodbye"
LogData=1
Name="SessionProc"
TypeName="Procedure"
Tag=""
Notes=""

[Object1]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Logging("OnsetDelay").Log=0
Logging("OnsetTime").Log=0
Logging("DurationError").Log=0
Logging("PreRelease").Log=0
Logging("Duration").Log=0
Logging("StartTime").Log=0
Logging("OffsetTime").Log=0
Logging("FinishTime").Log=0
Logging("TimingMode").Log=0
Logging("CustomOnsetTime").Log=0
Logging("CustomOffsetTime").Log=0
Logging("ActionDelay").Log=0
Logging("ActionTime").Log=0
Logging("TargetOffsetTime").Log=0
Logging("TargetOnsetTime").Log=0
Logging("OffsetDelay").Log=0
Logging("RTTime").Log=0
Logging("ACC").Log=0
Logging("RT").Log=0
Logging("RESP").Log=0
Logging("CRESP").Log=0
Logging("Tag").Log=0
Input(0)=!Data0
_VersionPersist=1
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Text="Welcome!\n\nThis experiment contains some script routines that will help configure your parallel port to read or write to the DATA port (pins 2-9).\n\nTo add these routines to your experiment, copy and paste all of the User script from this experiment to the User script area in your experiment and call the appropriate routines to configure your parallel port.\n\nIf you receive any errors while running this experiment, view the comments above the lines where the error occurs and contact E-Prime Web Support.\n\n\nPress any key to continue..."
ForeColor="black"
BackColor="white"
BackStyle="opaque"
BorderColor="black"
BorderWidth="0"
X="center"
Y="center"
Width="100%"
Height="100%"
XAlign="center"
YAlign="center"
AlignHorizontal="center"
AlignVertical="center"
FontName="Courier New"
FontSize="16"
FontBold="Yes"
FontItalic="No"
FontUnderline="No"
FontStrikeout="No"
WordWrap=1
ClearAfter="No"
Duration="-1"
JumpLabel=""
TimingMode=0
PreRelease="0"
OnsetSync=1
OffsetSync=0
Name="LookAtUserScript"
TypeName="TextDisplay"
Tag=""
Notes=""

[Data0]
DeviceName="Keyboard"
DeviceClass="Keyboard"
AllowableInput="{ANY}"
CorrectInput=""
TimeLimit=""
MaxCount="1"
InputAction=1
SyncOwnerDuration=1
Enabled=1
FlushInputBuffer="Yes"
TerminationInput=""
UserTag=""
ResponseMode="All"
ProcessBackspace="Yes"

[Object2]
_Version=131072
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
_VersionPersist=1
Code="\n\t'This is the port address used in this experiment\n\t' The default value for LPT1 is typically &H378\n\t' Adjust this value if your parallel port is located\n\t' at another address or if you have multiple parallel\n\t' ports in the machine.\n\tConst PORT_ADDRESS = &H378\n\n\n\t'Find out what type of parallel port is\n\t' configured on the system\n\tDim nPortType As Long\n\tnPortType = GetPortType(PORT_ADDRESS)\n\n\t'Get the human readable description\n\tDim strDescription As String\n\tstrDescription = GetPortDescription(PORT_ADDRESS)\n\n\t'Find out what the capabilities are\n\tDim strCapabilities As String\n\tSelect Case nPortType\n\t\tCase PORT_TYPE_SPP\n\t\t\tstrCapabilities = \"The parallel port is configured for legacy SPP (Output Only) mode.\" & _\n\t\t\t\t\t\t\t\t\"  You will not be able to use the ConfigurePortForInput or \" & _\n\t\t\t\t\t\t\t\t\"ConfigurePortForOutput routines in this function at this time.  \" & _\n\t\t\t\t\t\t\t\t\"Please configure the parallel port in the system BIOS \" & _\n\t\t\t\t\t\t\t\t\"and change the parallel port mode to ECP/EPP and run \" & _\n\t\t\t\t\t\t\t\t\"this experiment again.\"\n\n\t\t\t'Set the user break state so that we jump out of the experiment\n\t\t\tSetUserBreakState -1\n\n\t\tCase PORT_TYPE_PS2\n\t\t\tstrCapabilities = \"The parallel port is configured for legacy PS2 mode.\" & _\n\t\t\t\t\t\t\t\t\"  You will not be able to use the ConfigurePortForInput or \" & _\n\t\t\t\t\t\t\t\t\"ConfigurePortForOutput routines in this function at this time.  \" & _\n\t\t\t\t\t\t\t\t\"Please configure the parallel port in the system BIOS \" & _\n\t\t\t\t\t\t\t\t\"and change the parallel port mode to ECP/EPP and run \" & _\n\t\t\t\t\t\t\t\t\"this experiment again.\"\n\n\t\t\t'Set the user break state so that we jump out of the experiment\n\t\t\tSetUserBreakState -1\n\n\t\tCase PORT_TYPE_EPP, PORT_TYPE_ECP\n\t\t\tstrCapabilities = \"The parallel port is configured for the newer ECP/EPP modes.  \" & _\n\t\t\t\t\t\t\t\t\"Your computer is configured to use the script routines in \" & _\n\t\t\t\t\t\t\t\t\"this experiment.  Although all of the routines in the User \" & _\n\t\t\t\t\t\t\t\t\"script area can be called from an InLine in your experiment, \" & _ \n\t\t\t\t\t\t\t\t\"the major routines to note are ConfigurePortForInput and \" & _\n\t\t\t\t\t\t\t\t\"ConfigurePortForOutput as described on the following screens.\"\n\t\tCase Else\n\t\t\tstrCapabilities = \"The parallel port is configured for an unknown mode or an invalid port address was used.\" & _\n\t\t\t\t\t\t\t\t\"  You will not be able to use the ConfigurePortForInput or \" & _\n\t\t\t\t\t\t\t\t\"ConfigurePortForOutput routines in this function at this time.  \" & _\n\t\t\t\t\t\t\t\t\"Please configure the parallel port in the system BIOS \" & _\n\t\t\t\t\t\t\t\t\"and change the parallel port mode to ECP/EPP and run \" & _\n\t\t\t\t\t\t\t\t\"this experiment again.\"\n\n\t\t\t'Set the user break state so that we jump out of the experiment\n\t\t\tSetUserBreakState -1\n\n\tEnd Select\n\n\n\t'Set the values\n\tc.SetAttrib \"Description\", strDescription\n\tc.SetAttrib \"Capabilities\", strCapabilities\n\n\n\n"
Name="GetPortInfo"
TypeName="InLine"
Tag=""
Notes=""

[Object3]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Logging("OnsetDelay").Log=0
Logging("OnsetTime").Log=0
Logging("DurationError").Log=0
Logging("PreRelease").Log=0
Logging("Duration").Log=0
Logging("StartTime").Log=0
Logging("OffsetTime").Log=0
Logging("FinishTime").Log=0
Logging("TimingMode").Log=0
Logging("CustomOnsetTime").Log=0
Logging("CustomOffsetTime").Log=0
Logging("ActionDelay").Log=0
Logging("ActionTime").Log=0
Logging("TargetOffsetTime").Log=0
Logging("TargetOnsetTime").Log=0
Logging("OffsetDelay").Log=0
Logging("RTTime").Log=0
Logging("ACC").Log=0
Logging("RT").Log=0
Logging("RESP").Log=0
Logging("CRESP").Log=0
Logging("Tag").Log=0
Input(0)=!Data1
_VersionPersist=1
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Text="READING INPUT\n=============\n\nTo read input from the parallel port call ConfigurePortForInput(&&H378).  When you call ReadPort(&&H378) or use the PortDevice, the value returned will be the eight bits of data on the Data port of the parallel port (Pins 2-9).  Please note that the address does not need to be (base + 1) since you have configured the port for input.\n\n(Don't forget to connect your ground to one of the pins 18-25).\n\n\nPress any key to continue...\n\n\n* - &&H378 is typically the default address for LPT1."
ForeColor="black"
BackColor="white"
BackStyle="opaque"
BorderColor="black"
BorderWidth="0"
X="center"
Y="center"
Width="100%"
Height="100%"
XAlign="center"
YAlign="center"
AlignHorizontal="center"
AlignVertical="center"
FontName="Courier New"
FontSize="16"
FontBold="Yes"
FontItalic="No"
FontUnderline="No"
FontStrikeout="No"
WordWrap=1
ClearAfter="No"
Duration="-1"
JumpLabel=""
TimingMode=0
PreRelease="0"
OnsetSync=1
OffsetSync=0
Name="InputDisplay"
TypeName="TextDisplay"
Tag=""
Notes=""

[Data1]
DeviceName="Keyboard"
DeviceClass="Keyboard"
AllowableInput="{ANY}"
CorrectInput=""
TimeLimit=""
MaxCount="1"
InputAction=1
SyncOwnerDuration=1
Enabled=1
FlushInputBuffer="Yes"
TerminationInput=""
UserTag=""
ResponseMode="All"
ProcessBackspace="Yes"

[Object4]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Logging("OnsetDelay").Log=0
Logging("OnsetTime").Log=0
Logging("DurationError").Log=0
Logging("PreRelease").Log=0
Logging("Duration").Log=0
Logging("StartTime").Log=0
Logging("OffsetTime").Log=0
Logging("FinishTime").Log=0
Logging("TimingMode").Log=0
Logging("CustomOnsetTime").Log=0
Logging("CustomOffsetTime").Log=0
Logging("ActionDelay").Log=0
Logging("ActionTime").Log=0
Logging("TargetOffsetTime").Log=0
Logging("TargetOnsetTime").Log=0
Logging("OffsetDelay").Log=0
Logging("RTTime").Log=0
Logging("ACC").Log=0
Logging("RT").Log=0
Logging("RESP").Log=0
Logging("CRESP").Log=0
Logging("Tag").Log=0
Input(0)=!Data2
_VersionPersist=1
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Text="SENDING OUTPUT\n=============\n\nTo output date to the parallel port call ConfigurePortForOutput(&&H378).  When you call WritePort(&&H378, x) or use OnsetSignalXXX, the value sent will be the eight bits of data to the Data port of the parallel port (Pins 2-9).  \n\n(Don't forget to connect your ground to one of the pins 18-25).\n\n\nPress any key to continue...\n\n\n* - &&H378 is typically the default address for LPT1."
ForeColor="black"
BackColor="white"
BackStyle="opaque"
BorderColor="black"
BorderWidth="0"
X="center"
Y="center"
Width="100%"
Height="100%"
XAlign="center"
YAlign="center"
AlignHorizontal="center"
AlignVertical="center"
FontName="Courier New"
FontSize="16"
FontBold="Yes"
FontItalic="No"
FontUnderline="No"
FontStrikeout="No"
WordWrap=1
ClearAfter="No"
Duration="-1"
JumpLabel=""
TimingMode=0
PreRelease="0"
OnsetSync=1
OffsetSync=0
Name="OutputDisplay"
TypeName="TextDisplay"
Tag=""
Notes=""

[Data2]
DeviceName="Keyboard"
DeviceClass="Keyboard"
AllowableInput="{ANY}"
CorrectInput=""
TimeLimit=""
MaxCount="1"
InputAction=1
SyncOwnerDuration=1
Enabled=1
FlushInputBuffer="Yes"
TerminationInput=""
UserTag=""
ResponseMode="All"
ProcessBackspace="Yes"

[Object5]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Logging("OnsetDelay").Log=0
Logging("OnsetTime").Log=0
Logging("DurationError").Log=0
Logging("PreRelease").Log=0
Logging("Duration").Log=0
Logging("StartTime").Log=0
Logging("OffsetTime").Log=0
Logging("FinishTime").Log=0
Logging("TimingMode").Log=0
Logging("CustomOnsetTime").Log=0
Logging("CustomOffsetTime").Log=0
Logging("ActionDelay").Log=0
Logging("ActionTime").Log=0
Logging("TargetOffsetTime").Log=0
Logging("TargetOnsetTime").Log=0
Logging("OffsetDelay").Log=0
Logging("RTTime").Log=0
Logging("ACC").Log=0
Logging("RT").Log=0
Logging("RESP").Log=0
Logging("CRESP").Log=0
Logging("Tag").Log=0
_VersionPersist=1
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Text="Goodbye!\n\n\n\nThank you for supporting E-Prime!"
ForeColor="black"
BackColor="white"
BackStyle="opaque"
BorderColor="black"
BorderWidth="0"
X="center"
Y="center"
Width="100%"
Height="100%"
XAlign="center"
YAlign="center"
AlignHorizontal="center"
AlignVertical="center"
FontName="Courier New"
FontSize="18"
FontBold="Yes"
FontItalic="No"
FontUnderline="No"
FontStrikeout="No"
WordWrap=1
ClearAfter="No"
Duration="1000"
JumpLabel=""
TimingMode=0
PreRelease="0"
OnsetSync=1
OffsetSync=0
Name="Goodbye"
TypeName="TextDisplay"
Tag=""
Notes=""

[Object6]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Logging("OnsetDelay").Log=0
Logging("OnsetTime").Log=0
Logging("DurationError").Log=0
Logging("PreRelease").Log=0
Logging("Duration").Log=0
Logging("StartTime").Log=0
Logging("OffsetTime").Log=0
Logging("FinishTime").Log=0
Logging("TimingMode").Log=0
Logging("CustomOnsetTime").Log=0
Logging("CustomOffsetTime").Log=0
Logging("ActionDelay").Log=0
Logging("ActionTime").Log=0
Logging("TargetOffsetTime").Log=0
Logging("TargetOnsetTime").Log=0
Logging("OffsetDelay").Log=0
Logging("RTTime").Log=0
Logging("ACC").Log=0
Logging("RT").Log=0
Logging("RESP").Log=0
Logging("CRESP").Log=0
Logging("Tag").Log=0
Input(0)=!Data3
_VersionPersist=1
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Text="Your Current Port\n=================\n[Description]\n\n[Capabilities]\n\n\nPress any key to continue..."
ForeColor="black"
BackColor="white"
BackStyle="opaque"
BorderColor="black"
BorderWidth="0"
X="center"
Y="center"
Width="100%"
Height="100%"
XAlign="center"
YAlign="center"
AlignHorizontal="center"
AlignVertical="center"
FontName="Courier New"
FontSize="16"
FontBold="Yes"
FontItalic="No"
FontUnderline="No"
FontStrikeout="No"
WordWrap=1
ClearAfter="No"
Duration="-1"
JumpLabel=""
TimingMode=0
PreRelease="0"
OnsetSync=1
OffsetSync=0
Name="PortInfo"
TypeName="TextDisplay"
Tag=""
Notes=""

[Data3]
DeviceName="Keyboard"
DeviceClass="Keyboard"
AllowableInput="{ANY}"
CorrectInput=""
TimeLimit=""
MaxCount="1"
InputAction=1
SyncOwnerDuration=1
Enabled=1
FlushInputBuffer="Yes"
TerminationInput=""
UserTag=""
ResponseMode="All"
ProcessBackspace="Yes"

[Object7]
_Version=131072
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
_VersionPersist=1
Code="\n\n\t'If the InLine above set the user break state, then\n\t' we jump to the goodbye\n\tIf GetUserBreakState <> 0 Then GoTo GoodbyeLabel"
Name="CheckContinue"
TypeName="InLine"
Tag=""
Notes=""

[Object8]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
_VersionPersist=1
Name="GoodbyeLabel"
TypeName="Label"
Tag=""
Notes=""

[Object9]
_Version=65536
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Logging("OnsetDelay").Log=0
Logging("OnsetTime").Log=0
Logging("DurationError").Log=0
Logging("PreRelease").Log=0
Logging("Duration").Log=0
Logging("StartTime").Log=0
Logging("OffsetTime").Log=0
Logging("FinishTime").Log=0
Logging("TimingMode").Log=0
Logging("CustomOnsetTime").Log=0
Logging("CustomOffsetTime").Log=0
Logging("ActionDelay").Log=0
Logging("ActionTime").Log=0
Logging("TargetOffsetTime").Log=0
Logging("TargetOnsetTime").Log=0
Logging("OffsetDelay").Log=0
Logging("RTTime").Log=0
Logging("ACC").Log=0
Logging("RT").Log=0
Logging("RESP").Log=0
Logging("CRESP").Log=0
Logging("Tag").Log=0
Input(0)=!Data4
_VersionPersist=1
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
Text="Although all of the routines in the User script provided can be called from an InLine, typically all you will need to do is place a call to ConfigurePortForInput or ConfigurePortForOutput.\n\nOnce you configure the port for the direct you want the data to go on the DATA port (pins 2-9), then you would use the same approach as you would have w/o the configuring commands.\n\nFor example, continue to use PortDevice, ReadPort, WritePort, Onset/OffsetSignalXXX.\n\nPress any key..."
ForeColor="black"
BackColor="white"
BackStyle="opaque"
BorderColor="black"
BorderWidth="0"
X="center"
Y="center"
Width="100%"
Height="100%"
XAlign="center"
YAlign="center"
AlignHorizontal="center"
AlignVertical="center"
FontName="Courier New"
FontSize="18"
FontBold="Yes"
FontItalic="No"
FontUnderline="No"
FontStrikeout="No"
WordWrap=1
ClearAfter="No"
Duration="-1"
JumpLabel=""
TimingMode=0
PreRelease="0"
OnsetSync=1
OffsetSync=0
Name="ConfigureAndGo"
TypeName="TextDisplay"
Tag=""
Notes=""

[Data4]
DeviceName="Keyboard"
DeviceClass="Keyboard"
AllowableInput="{ANY}"
CorrectInput=""
TimeLimit=""
MaxCount="1"
InputAction=1
SyncOwnerDuration=1
Enabled=1
FlushInputBuffer="Yes"
TerminationInput=""
UserTag=""
ResponseMode="All"
ProcessBackspace="Yes"

[Object10]
_Version=131072
_ExtentX=2646
_ExtentY=1323
_StockProps=0
VersionMajor=1
VersionMinor=2
VersionInternal=1
VersionBuild=67
_VersionPersist=1
Code="\n\n\t'Configure the port for output\n\t' After this call, use WritePort PORT_ADDRESS, 1\n\t' to set the LSB (pin 2) high or set the OnsetSignalXXX\n\t' properties of an object.\n\tConfigurePortForOutput PORT_ADDRESS\n\n\n\t'Configure the port for input\n\t' After this call, use x = ReadPort(PORT_ADDRESS)\n\t' or use the PortDevice in the Duration/Input\n\t' property page of an object.  Note that\n\t' you do not need to use &379 (base + 1) to \n\t' read the data since you are reading from\n\t' the DATA port (pins 2-9)\n\tConfigurePortForInput PORT_ADDRESS\n\n\n\t"
Name="ExampleCalls"
TypeName="InLine"
Tag=""
Notes=""

[UserScript]

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'	PARALLEL PORT ROUTINES - BEGIN
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'	Version:	1.0.0.1
'	Date:		9/23/03
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Const PORT_TYPE_UNKNOWN = 0
Const PORT_TYPE_SPP = 1
Const PORT_TYPE_PS2 = 2
Const PORT_TYPE_EPP = 3
Const PORT_TYPE_ECP = 4

Const ECP_MODE_SPP = 0
Const ECP_MODE_PS2 = 1
Const ECP_MODE_FAST_CENTRONICS = 2
Const ECP_MODE_ECP = 3
Const ECP_MODE_EPP = 4
Const ECP_MODE_TEST = 6
Const ECP_MODE_CONFIGURATION = 7

Function DataPortRead(ByVal nBaseAddress As Long) As Integer
	DataPortRead = ReadPort(nBaseAddress)
End Function

Sub DataPortWrite(ByVal nBaseAddress As Long, ByVal nValue As Integer)
	WritePort nBaseAddress, nValue
End Sub

Function StatusPortRead(ByVal nBaseAddress As Long) As Integer
	'Reads a parallel port's status port.
	'Calculates the status-port address from the port's
	'base address, and inverts bit 7 of the byte read.
	'The status-port hardware reinverts these bits,
	'so the value read matches the value at the connector.
	StatusPortRead = (ReadPort(nBaseAddress + 1) Xor &H80)
End Function

Function BitRead(ByVal nSource As Long, ByVal nBitNumber As Integer) As Long
	
	'Returns the value (0 or 1) of the requested bit in a Variable.
	Dim nBitValue As Long

	'the value of the requested bit
	nBitValue = 2 ^ nBitNumber 

	BitRead = (nSource And nBitValue) \ nBitValue

End Function

Function BitReset(ByVal nSource As Long, ByVal nBitNumber As Integer) As Long
	
	'Resets (clears) the requested bit in a Variable.
	Dim nBitValue As Long
	Dim nCurrentValue As Long

	'The value of the requested bit.
	nBitValue = 2 ^ nBitNumber
	BitReset = nSource And (&HFFFFFFFF - nBitValue)

End Function

Function BitSet(ByVal nSource As Long, ByVal nBitNumber As Integer) As Long
	
	'Sets the requested bit in a Variable.
	Dim nBitValue As Long
	
	'The value of the requested bit.
	nBitValue = 2 ^ nBitNumber
	BitSet = nSource Or nBitValue

End Function

Function BitToggle(ByVal nSource As Long, ByVal nBitNumber As Integer) As Long
	
	'Toggles the requested bit in a Variable.
	Dim nBitValue As Long
	Dim nCurrentValue As Long

	'The value of the requested bit.
	nBitValue = 2 ^ nBitNumber
	
	'Is the current value 0 or 1?
	nCurrentValue = nSource And nBitValue
	Select Case nCurrentValue
	    Case 0
	        'If current value = 0, set it
	        BitToggle = nSource Or nBitValue
	    Case Else
	        'If current value = 1, reset it
	        BitToggle = nSource And (&HFFFFFFFF - nBitValue)
	End Select
End Function

Function ControlPortRead(ByVal nBaseAddress As Long) As Integer

	'Reads a parallel port's control port.
	'Calculates the control-port address from the port's
	'base address, and inverts bits 0, 1, & 3 of the byte read.
	'The control-port hardware reinverts these bits,
	'so the value read matches the value at the connector.
	ControlPortRead = (ReadPort(nBaseAddress + 2) Xor &HB)

End Function

Sub ControlPortWrite(ByVal nBaseAddress As Long, ByVal nValue As Integer)

	'Writes a Value to a parallel port's control port.
	'Calculates the control-port address from the port's
	'base address, and inverts bits 0, 1, & 3.
	'The control-port hardware reinverts these bits,
	'so Value is written to the port connector.
	WritePort nBaseAddress + 2, nValue Xor &HB

End Sub

Function GetEcpMode(ByVal nBaseAddress As Long) As Integer

	Dim nEcrAddress As Long
	Dim nEcrData As Long

	'The Ecr mode is in bits 5, 6, and 7 of the ECR.
	nEcrAddress = nBaseAddress + &H402
	nEcrData = ReadPort(nEcrAddress)
	GetEcpMode = (nEcrData And &HE0) \ &H20

End Function

Function GetEppTimeoutBit(ByVal nBaseAddress As Long) As Integer

	'Reads and clears the EPP timeout bit (status port bit 0).
	'Should be done after each EPP operation.
	'The method for clearing the bit varies, so try 3 ways:
	'1. Write 1 to it.
	'2. Write 0 to it.
	'3. Read it again.
	Dim nStatusPortAddress As Long
	Dim nReadAgain As Long
	nStatusPortAddress = nBaseAddress + 1
	GetEppTimeoutBit = BitRead(StatusPortRead(nBaseAddress), 0)
	WritePort nStatusPortAddress, 1
	WritePort nStatusPortAddress, 0
	nReadAgain = BitRead(StatusPortRead(nBaseAddress), 0)

End Function

Function IsPortEcp(ByVal nBaseAddress As Long) As Boolean

	'Test for the presence of an ECP.
	'If the ECP is idle and the FIFO empty,
	'in the ECP's Ecr (at Base Address+402h),
	'bit 1(Fifo full)=0, and bit 0(Fifo empty)=1.
	'The first test is to see if these bits differ from the
	'corresponding bits in the control port (at Base Address+2).
	'If so, a further test is to write 34h to the Ecr,
	'then read it back. Bit 1 is read/write, and bit 0 is read-only.
	'If the value read is 35h, the port is an ECP.
	Dim nEcrBit0 As Long
	Dim nEcrBit1 As Long
	Dim nControlBit0 As Long
	Dim nControlBit1 As Long
	Dim nControlPortData As Long
	Dim nOriginalControlPortData As Long
	Dim nTestEcrAddress As Long
	Dim nOriginalEcrData As Long
	Dim nEcrAddress As Long
	Dim nEcrData As Long

	'Guilty until proven innocent	
	IsPortEcp = False

	nEcrAddress = nBaseAddress + &H402

	'Read ECR bits 0 & 1 and Control Port bit 1.
	nEcrData = ReadPort(nEcrAddress)
	nEcrBit0 = BitRead(nEcrData, 0)
	nEcrBit1 = BitRead(nEcrData, 1)
	nOriginalControlPortData = ControlPortRead(nBaseAddress)
	nControlPortData = nOriginalControlPortData
	nControlBit1 = BitRead(nControlPortData, 1)
	If nEcrBit0 = 1 And nEcrBit1 = 0 Then
	    'Compare control bit 1 to ECR bit 1.
	    'Toggle the control bit if necessary,
	    'to be sure the two registers are different.
	    If nControlBit1 = 0 Then
	        ControlPortWrite nBaseAddress, &HF
	        nControlPortData = ControlPortRead(nBaseAddress)
	        nControlBit1 = BitRead(nControlPortData, 1)
	    End If

	    If nEcrBit1 <> nControlBit1 Then
	        nOriginalEcrData = nEcrData
	        WritePort nEcrAddress, &H34
	        nEcrData = ReadPort(nEcrAddress)
	        If nEcrData = &H35 Then
	            IsPortEcp = True
	        End If

	        'Restore the ECR to its original value.
	        WritePort nEcrAddress, nOriginalEcrData

	    End If
	End If

	'Restore the control to its original value.
	ControlPortWrite nBaseAddress, nOriginalControlPortData

End Function


Function IsPortEpp(ByVal nBaseAddress As Long) As Boolean

	'Write to an Epp register, then read it back.
	'If the reads match the writes, it's probably an Epp.
	Dim nByteRead As Long
	Dim nStatusPortData As Long
	Dim nEppAddressPort As Long
	Dim nTimeoutBit As Long
	Dim nStatusPortAddress As Long
	nStatusPortAddress = nBaseAddress + 1

	'Guilty until proven innocent
	IsPortEpp = False

	'Use EppAddressPort for testing.
	'SPPs, ECPs, and PS/2 ports don't have this register.
	nEppAddressPort = nBaseAddress + 3
	WritePort nEppAddressPort, &H55

	'Clear the timeout bit after each EPP operation.
	nTimeoutBit = GetEppTimeoutBit(nBaseAddress)
	nByteRead = ReadPort(nEppAddressPort)
	nTimeoutBit = GetEppTimeoutBit(nBaseAddress)
	If nByteRead = &H55 Then
	    WritePort nEppAddressPort, &HAA
	    nTimeoutBit = GetEppTimeoutBit(nBaseAddress)
	    nByteRead = ReadPort(nEppAddressPort)
	    nTimeoutBit = GetEppTimeoutBit(nBaseAddress)
	    If nByteRead = &HAA Then
	        IsPortEpp = True
	    End If
	End If

End Function

Function IsPortSpp(ByVal nBaseAddress As Long) As Boolean

	'Write two bytes and read them back.
	'If the reads match the writes, the port exists.
	Dim nByteRead As Long

	'Attempt to cache the control port data
	Dim nOriginalControlPortData As Long
	nOriginalControlPortData = ControlPortRead(nBaseAddress)

	'Be sure that control port bit 5 = 0 (data outputs enabled).
	ControlPortWrite nBaseAddress, &HF

	'Guilty until proven innocent
	IsPortSpp = False

	'Write to the data port
	DataPortWrite nBaseAddress, &H55

	'Read the byte back
	nByteRead = DataPortRead(nBaseAddress)

	'Is it the same?
	If nByteRead = &H55 Then

		'Write another byte to confirm
	    DataPortWrite nBaseAddress, &HAA
	    
		'Read the byte back
		nByteRead = DataPortRead(nBaseAddress)

		'Is it the same?
	    If nByteRead = &HAA Then
	        IsPortSpp = True
	    End If

	End If

	'Attempt to restore the control port data
	ControlPortWrite nBaseAddress, nOriginalControlPortData

End Function

Function IsPortPS2(ByVal nBaseAddress As Long) As Boolean
	
	'A PS/2 port must pass the SPP test
	If Not IsPortSpp(nBaseAddress) Then Exit Function

	'Tests a parallel port's data port for bidirectional ability.
	'First, try to tri-state (disable) the data outputs by
	'setting bit 5 of the Control port.
	'Then write 2 values to the data port and read each back
	'If the values match, the data outputs are not disabled,
	'and the port is not bidirectional.
	'If the values don't match,
	'the data outputs are disabled and the port is bidirectional.
	Dim nDataInput As Long
	Dim nControlPortData As Long
	Dim nOriginalDataPortData As Long

	'Attempt to cache the control port data
	Dim nOriginalControlPortData As Long
	nOriginalControlPortData = ControlPortRead(nBaseAddress)


	'Set Control port bit 5.
	ControlPortWrite nBaseAddress, &H2F

	'Guilty until proven innocent
	IsPortPS2 = False

	'Write the first byte and read it back:
	DataPortWrite nBaseAddress, &H55
	nDataInput = DataPortRead(nBaseAddress)

	'If it doesn't match, the port is bidirectional.
	If Not nDataInput = &H55 Then IsPortPS2 = True

	'If it matches, write another and read it back.
	If nDataInput = &H55 Then
	    DataPortWrite nBaseAddress, &HAA
	    nDataInput = DataPortRead(nBaseAddress)

	    'If it doesn't match, the port is bidirectional
	    If Not nDataInput = &HAA Then
	        IsPortPS2 = True
	    End If
	End If

	'Attempt to restore the control port data
	ControlPortWrite nBaseAddress, nOriginalControlPortData

End Function

Function IsPortOutput(ByVal nAddress As Long) As Boolean

	'Guilty until proven innocent
	IsPortOutput = False

	'Get the value of the control port if bit five is
	' high, then set for input.  If the bit is low,
	' then set for output.  NOTE that on some odd ports,
	' you must set bit seven and this function would be incorrect
	Dim nControlPortValue As Long
	nControlPortValue = ControlPortRead(nAddress)

	'0 = Output
	If BitRead(nControlPortValue, 5) = 0 Then
		IsPortOutput = True
	End If

End Function

Function IsPortInput(ByVal nAddress As Long) As Boolean

	'Guilty until proven innocent
	IsPortInput = False

	'Get the value of the control port if bit five is
	' high, then set for input.  If the bit is low,
	' then set for output.  NOTE that on some odd ports,
	' you must set bit seven and this function would be incorrect
	Dim nControlPortValue As Long
	nControlPortValue = ControlPortRead(nAddress)

	'1 = input
	If BitRead(nControlPortValue, 5) = 1 Then
		IsPortInput = True
	End If

End Function

Function GetPortType(ByVal nBaseAddress As Long) As Long

	'Test for a port's presence, and if it exists, the type of port.
	'In order, check for the presence of an ECP, EPP, SPP, and PS/2 port.
	'Update the information in the Port array  and the display.
	
	'Check for ECP
	If IsPortEcp(nBaseAddress) Then
	
		GetPortType = PORT_TYPE_ECP
		Exit Function
	    
	End If

    'If it's not an ECP, look for an EPP.
    'If BaseAddress = 3BCh, skip the EPP test.
    'EPPs aren't allowed at 3BCh due to possible conflict
    'with video memory.
    If nBaseAddress <> &H3BC Then
        If IsPortEpp(nBaseAddress) Then
			GetPortType = PORT_TYPE_EPP
			Exit Function
		End If
    End If

    'If it's not an EPP, look for a PS/2.
	If IsPortPS2(nBaseAddress) Then
		
		GetPortType = PORT_TYPE_PS2
		Exit Function

	End If

	'Well, must be an SPP
	If IsPortSPP(nBaseAddress) Then

		GetPortType = PORT_TYPE_SPP
		Exit Function

	End If

	'Why did we get here - nothing passed!
	'Is the port address not a parallel port?
	Debug.Assert False
	GetPortType = PORT_TYPE_UNKNOWN

End Function

Sub SetEcpMode(ByVal nBaseAddress As Long, ByVal nEcpModeValue As Integer)

	'Why are you calling this on a port that is not ECP?
	Debug.Assert IsPortEcp(nBaseAddress)

	'Why are you setting an invalid mode?
	Debug.Assert nEcpModeValue = ECP_MODE_SPP Or _
				nEcpModeValue = ECP_MODE_PS2 Or _
				nEcpModeValue = ECP_MODE_FAST_CENTRONICS Or _
				nEcpModeValue = ECP_MODE_ECP Or _
				nEcpModeValue = ECP_MODE_EPP Or _
				nEcpModeValue = ECP_MODE_TEST Or _
				nEcpModeValue = ECP_MODE_CONFIGURATION

	Dim nEcrAddress As Integer
	Dim nEcrData As Integer
	nEcrAddress = nBaseAddress + &H402

	'Read the ECR & clear bits 5, 6, 7.
	nEcrData = ReadPort(nEcrAddress) And &H1F

	'Write the selected value to bits 5, 6, 7.
	nEcrData = nEcrData + nEcpModeValue * &H20
	WritePort nEcrAddress, nEcrData

End Sub

Sub ConfigurePortForInput(ByVal nBaseAddress As Long)

	'If the port is SPP, then input is not permitted through the DATA port
	If GetPortType(nBaseAddress) = PORT_TYPE_SPP Then
		
		'If the port is SPP, then input is not permitted through the DATA port
		'Configure the port through the BIOS, etc. for ECP, EPP, PS2, Bi-Direction.
		'Input from an SPP must be done through the Status or Control ports as
		' access to the DATA port is for output only.
		'Please see KB:1320 for more information on the E-Prime Web Support site.
		Debug.Assert False

	End If

	'If the port is and ECP port, configure its compatability mode for PS/2 for Bi-Directional
	If IsPortEcp(nBaseAddress) Then SetEcpMode nBaseAddress, ECP_MODE_PS2

	Dim nControlValue As Long
	nControlValue = ControlPortRead(nBaseAddress)

	'Set bits five and seven to indicate the port is for input
	nControlValue = BitSet(nControlValue, 5)
	nControlValue = BitSet(nControlValue, 7)

	'Update the register
	ControlPortWrite nBaseAddress, nControlValue

End Sub

Sub ConfigurePortForOutput(ByVal nBaseAddress As Long)

	'If the port is and ECP port, configure its compatability mode for standard output only
	If IsPortEcp(nBaseAddress) Then SetEcpMode nBaseAddress, ECP_MODE_SPP

	Dim nControlValue As Long
	nControlValue = ControlPortRead(nBaseAddress)

	'RESET bits five and seven to zero indicating output
	nControlValue = BitReset(nControlValue, 5)
	nControlValue = BitReset(nControlValue, 7)

	'Update the register
	ControlPortWrite nBaseAddress, nControlValue

End Sub

Function GetPortDescription(ByVal nBaseAddress As Long) As String

	Dim strDescription As String
	strDescription = strDescription & "Type: "

	'Get the Type
	Dim nPortType As Long
	nPortType = GetPortType(nBaseAddress)

	Select Case nPortType
		Case PORT_TYPE_SPP
			strDescription = strDescription & "SPP (Output Only)"
		Case PORT_TYPE_PS2
			strDescription = strDescription & "PS/2 (Bi-Directional)"
		Case PORT_TYPE_EPP
			strDescription = strDescription & "EPP"
		Case PORT_TYPE_ECP
			strDescription = strDescription & "ECP"
		Case Else
			strDescription = strDescription & "UNKNOWN(" & nPortType & ")"
	End Select

	'If ECP, then get compatability mode
	If nPortType = PORT_TYPE_ECP Then
	
		'Compatabilty mode
		strDescription = strDescription & " Compatability: "
		
		Dim nEcpMode As Long
		nEcpMode = GetEcpMode(nBaseAddress)

		Select Case nEcpMode
			Case ECP_MODE_SPP
				strDescription = strDescription & "SPP"
			Case ECP_MODE_PS2
				strDescription = strDescription & "PS/2"
			Case ECP_MODE_FAST_CENTRONICS
				strDescription = strDescription & "Fast Centronics"			
			Case ECP_MODE_EPP
				strDescription = strDescription & "EPP"
			Case ECP_MODE_ECP
				strDescription = strDescription & "ECP"
			Case ECP_MODE_TEST
				strDescription = strDescription & "Test"
			Case ECP_MODE_CONFIGURATION
				strDescription = strDescription & "Configuration"			
			Case Else
				strDescription = strDescription & "UNKNOWN(" & nEcpMode & ")"
		End Select
	End If

	'Can we currently write to the port?
	If IsPortOutput(nBaseAddress) Then
		strDescription = strDescription & " DATA PORT: output"
	End If

	'Can we currently read from the port?
	If IsPortInput(nBaseAddress) Then
		strDescription = strDescription & " DATA PORT: input"
	End If

	'Assign return
	GetPortDescription = strDescription

End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'	PARALLEL PORT ROUTINES - END
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

