simultaneous response

David McFarlane mcfarla9 at msu.edu
Fri Feb 8 15:13:21 UTC 2008


Egbert,

Attached is the program I promised that just shows the raw input from 
keyboard or SRBox.  These are in E-Prime 1, two programs that do the 
same thing with slightly different programming techniques (I'm a bit 
obsessive about this), and both the .es and .ebs file.

Regards,
-- David
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

-------------- next part --------------
'
'
'
'	C:\Documents and Settings\fmri\My Documents\My Experiments\ShowRawInput\ShowRawInput (loop using Inline script).ebs
'	Generated on: 11/27/2006	15:28:01
'
'
'	This file generated with E-Studio interface.
'	E-Prime Copyright ? 2002 Psychology Software Tools.
'	ALL RIGHTS RESERVED

'	Legal use of this experiment script requires a full E-Prime or Runtime License.
'
'
'	Author:
'		David McFarlane (Michigan State University)
'
'
'
'

Option CStrings On
Dim ebContext as Context


'--------------------------------------------------------------------------
' Class Declarations
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
'InitSlideStateDefaults
'--------------------------------------------------------------------------
Sub InitSlideStateDefaults(theSlideState As SlideState)

	If theSlideState Is Nothing Then Exit Sub

	theSlideState.X = "center"
	theSlideState.Y = "center"
	theSlideState.Width = "100%"
	theSlideState.Height = "100%"
	theSlideState.BackColor = CColor("white")
	theSlideState.BackStyle = "opaque"
	theSlideState.BorderColor = CColor("black")
	theSlideState.BorderWidth = CLng("0")
	theSlideState.XAlign = "center"
	theSlideState.YAlign = "center"
	theSlideState.ClearAfter = CLogical("No")
	theSlideState.Enabled = CLogical("Yes")

End Sub

'--------------------------------------------------------------------------
'InitSlideVisualStimDefaults
'--------------------------------------------------------------------------
Sub InitSlideVisualStimDefaults(theSlideVisualStim As SlideVisualStim)

	If theSlideVisualStim Is Nothing Then Exit Sub

	theSlideVisualStim.X = "center"
	theSlideVisualStim.Y = "center"
	theSlideVisualStim.Width = "25%"
	theSlideVisualStim.Height = "25%"
	theSlideVisualStim.ForeColor = CColor("black")
	theSlideVisualStim.BackColor = CColor("white")
	theSlideVisualStim.BackStyle = "opaque"
	theSlideVisualStim.BorderColor = CColor("black")
	theSlideVisualStim.BorderWidth = CLng("0")
	theSlideVisualStim.XAlign = "center"
	theSlideVisualStim.YAlign = "center"
	theSlideVisualStim.AlignHorizontal = "center"
	theSlideVisualStim.AlignVertical = "center"

End Sub

'--------------------------------------------------------------------------
'InitSlideTextDefaults
'--------------------------------------------------------------------------
Sub InitSlideTextDefaults(theSlideText As SlideText)

	If theSlideText Is Nothing Then Exit Sub

	InitSlideVisualStimDefaults theSlideText

	theSlideText.WordWrap = True
	theSlideText.FontName = "Courier New"
	theSlideText.FontSize = "18"
	theSlideText.FontBold = CLogical("Yes")
	theSlideText.FontItalic = CLogical("No")
	theSlideText.FontUnderline = CLogical("No")
	theSlideText.FontStrikeout = CLogical("No")

End Sub

'--------------------------------------------------------------------------
'InitSlideImageDefaults
'--------------------------------------------------------------------------
Sub InitSlideImageDefaults(theSlideImage As SlideImage)

	If theSlideImage Is Nothing Then Exit Sub

	InitSlideVisualStimDefaults theSlideImage

	theSlideImage.Stretch = CLogical("No")
	theSlideImage.MirrorLeftRight = CLogical("No")
	theSlideImage.MirrorUpDown = CLogical("No")
	theSlideImage.UseSourceColorKey = CLogical("No")
	theSlideImage.SourceColorKey = CColor("black")

End Sub

'--------------------------------------------------------------------------
'InitSlideSoundBufferDefaults
'--------------------------------------------------------------------------
Sub InitSlideSoundBufferDefaults(theSoundBuffer As SoundBuffer)

	If theSoundBuffer Is Nothing Then Exit Sub

	theSoundBuffer.Loop = CLogical("No")
	theSoundBuffer.StopAfter = CLogical("Yes")
	theSoundBuffer.StartOffset = "0"
	theSoundBuffer.StopOffset = "0"

End Sub




'--------------------------------------------------------------------------
' Instance Declarations
'--------------------------------------------------------------------------
Dim Display As DisplayDevice
Dim Sound As SoundDevice
Dim Keyboard As KeyboardDevice
Dim Mouse As MouseDevice
Dim SRBOX As SRBOXDevice
Dim SessionProc As Procedure

Dim Slide1 As Slide
Dim Slide1EchoClients As EchoClientCollection
Dim Slide1_State As SlideState
Dim Slide1_SlideText As SlideText



'--------------------------------------------------------------------------
' Package Declare Script
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' User Script
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' Package Global Script
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' Package Routines
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' Implementation
'--------------------------------------------------------------------------
Sub SessionProc_Run(c as Context)
	
	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - InitSession BEGIN
	'''''''''''''''''''''''''''''''''''''''''''''
	Dim i as integer
	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - InitSession END
	'''''''''''''''''''''''''''''''''''''''''''''
	
	
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'	Label - LoopBegin BEGIN
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

LoopBegin:
	If Err.Number = ebInputAccepted Then
		Err.Clear
		Resume LoopBeginResume
	ElseIf Err.Number <> 0 Then
		'NOTE: If you receive a runtime error here, it
		' is because a runtime error other than ebInputAccepted
		' was thrown (ebInputAccepted for catching input masks that jump).
		'You are encouraged to either handle the error so that
		' it is not thrown in the future or will have to set up
		' your own error handler, which will also need to take
		' into account for any input masks that jump.
		'
		'Raise the error so the default error handler will show the message
		Err.Raise Err.Number
	End If

LoopBeginResume:

	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'	Label - LoopBegin END
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

	
	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - SetSlide1 BEGIN
	'''''''''''''''''''''''''''''''''''''''''''''
	if Slide1.RESP <> "" then
    beep
	i = i + 1
	Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects("i"))
	Slide1_SlideText.Text = i
	Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects("Response"))
	Slide1_SlideText.Text = Slide1.RESP
	Set Slide1_SlideText = Nothing
	c.PushNewFrame
	c.SetAttrib "Slide1.RESP", Slide1.RESP
	c.Log
	c.PopFrame
end if

	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - SetSlide1 END
	'''''''''''''''''''''''''''''''''''''''''''''
	
	
	
	Select Case Slide1.ActiveState
		Case "Default"


			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(1))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(2))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(3))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(4))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(5))
			Set Slide1_SlideText = Nothing
	End Select

	
	Slide1.InputMasks.Reset
	
	Slide1EchoClients.RemoveAll
	Slide1.InputMasks.Add Keyboard.CreateInputMask("{ANY}", "", CLng(Slide1.Duration), CLng("1"), ebEndResponseActionTerminate, CLogical("Yes"), "", "", "ResponseMode:All ProcessBackspace:Yes")

	
	Slide1EchoClients.RemoveAll
	Slide1.InputMasks.Add SRBOX.CreateInputMask("{ANY}", "", CLng(Slide1.Duration), CLng("1"), ebEndResponseActionTerminate, CLogical("Yes"), "", "", "")

	
	Slide1.Run
	
	
	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - LoopTest BEGIN
	'''''''''''''''''''''''''''''''''''''''''''''
	if GetUserBreakState() = 0 then goto LoopBegin

	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - LoopTest END
	'''''''''''''''''''''''''''''''''''''''''''''
	

	c.Log
End Sub





'--------------------------------------------------------------------------
' InitDevices
'
'--------------------------------------------------------------------------
Sub InitDevices(c As Context)



	SetOSThreadPriority 3


	Set Display = New DisplayDevice
	Display.Name = "Display"

	Dim DisplayDisplayDeviceInfo As DisplayDeviceInfo
	DisplayDisplayDeviceInfo.XRes = 640
	DisplayDisplayDeviceInfo.YRes = 480
	DisplayDisplayDeviceInfo.ColorDepth = 16
	DisplayDisplayDeviceInfo.RefreshRate = 0
	DisplayDisplayDeviceInfo.NumPages = 0

	Display.Open DisplayDisplayDeviceInfo
	c.SetAttrib "Display.RefreshRate", Format$(Display.CalculatedRefreshRate, "0.000")

	Set Sound = New SoundDevice
	Sound.Name = "Sound"

	Dim SoundSoundOutDeviceInfo As SoundDeviceInfo
	SoundSoundOutDeviceInfo.Channels = 2
	SoundSoundOutDeviceInfo.SamplesPerSecond = 22050
	SoundSoundOutDeviceInfo.BitsPerSample = 16
	
	Set Keyboard = New KeyboardDevice
	Keyboard.Name = "Keyboard"

	Dim KeyboardKeyboardDeviceInfo as KeyboardDeviceInfo
	KeyboardKeyboardDeviceInfo.CollectionMode = ebPressesAndReleases
	KeyboardKeyboardDeviceInfo.CapsLock = ebCapsLockOff
	KeyboardKeyboardDeviceInfo.NumLock = ebNumLockOn
	Keyboard.Open KeyboardKeyboardDeviceInfo
	
	Set Mouse = New MouseDevice
	Mouse.Name = "Mouse"

	Dim MouseMouseDeviceInfo as MouseDeviceInfo
	MouseMouseDeviceInfo.OpenMode = ebMouseOpenModeDirect
	MouseMouseDeviceInfo.CollectionMode = ebPressesOnly
	MouseMouseDeviceInfo.ShowCursor = False
	Mouse.Open MouseMouseDeviceInfo

	Set SRBOX = New SRBoxDevice
	SRBOX.Name = "SRBOX"

	Dim SRBOXSRBoxDeviceInfo As SRBoxDeviceInfo
	SRBOXSRBoxDeviceInfo.Model = 200
	SRBOXSRBoxDeviceInfo.Revision = 1
	SRBOXSRBoxDeviceInfo.CommPort = 1
	SRBOXSRBoxDeviceInfo.BaudRate = 19200
	SRBOXSRBoxDeviceInfo.CharacterRate = 800
	SRBOXSRBoxDeviceInfo.Configuration = ebSRBoxConfigBRUUnique
	SRBOXSRBoxDeviceInfo.CollectionMode = ebPressesAndReleases
	SRBOX.Open SRBOXSRBoxDeviceInfo


	SetOSThreadPriority 0

End Sub



'--------------------------------------------------------------------------
' InitObjects
'
'--------------------------------------------------------------------------
Sub InitObjects(c As Context)

	Set SessionProc = New Procedure
	SessionProc.Name = "SessionProc"
	SessionProc.Tag = ""
	SessionProc.Subroutine = "SessionProc_Run"

	Set Slide1 = New Slide
	Slide1.Name = "Slide1"
	Slide1.Tag = ""

	Set Slide1EchoClients = New EchoClientCollection
	Slide1.Duration = CLng("1000")
	Slide1.TimingMode = ebTimingModeEvent
	Slide1.PreRelease = Val("0")

	Slide1.OnsetSync = 1
	Slide1.OffsetSync = 0

	Set Slide1_State = New SlideState
	Slide1_State.Name = "Default"

	InitSlideStateDefaults Slide1_State


	Slide1.States.Add Slide1_State, "Default"


	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "ResponseLabel"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = "Response = "
	Slide1_SlideText.Y = "50%"
	Slide1_SlideText.Width = "30%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "right"
	Slide1_SlideText.AlignHorizontal = "right"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "ResponseLabel"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "iLabel"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = "# "
	Slide1_SlideText.Y = "45%"
	Slide1_SlideText.Width = "5%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "right"
	Slide1_SlideText.AlignHorizontal = "right"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "iLabel"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "Response"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = ""
	Slide1_SlideText.Y = "50%"
	Slide1_SlideText.Width = "30%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "left"
	Slide1_SlideText.AlignHorizontal = "left"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "Response"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "Info"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = "Press any key or button to see the result below.\nPress <CTRL><SHIFT> to exit.\n"
	Slide1_SlideText.Y = "25%"
	Slide1_SlideText.Width = "80%"
	Slide1_SlideText.Height = "15%"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "Info"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "i"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = ""
	Slide1_SlideText.Y = "45%"
	Slide1_SlideText.Width = "10%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "left"
	Slide1_SlideText.AlignHorizontal = "left"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "i"
	Slide1.ActiveState = "Default"


End Sub


'--------------------------------------------------------------------------
' InitPackages
'
'--------------------------------------------------------------------------
Sub InitPackages(c As Context)

End Sub



'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
' UnInitDevices
'--------------------------------------------------------------------------
Sub UnInitDevices()
	Display.Close
	Set Display = Nothing

	Keyboard.Close
	Set Keyboard = Nothing

	Mouse.Close
	Set Mouse = Nothing


	SRBOX.Close
	Set SRBOX = Nothing

End Sub


'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
' UnInitPackages
'--------------------------------------------------------------------------
Sub UnInitPackages()
End Sub


'--------------------------------------------------------------------------
' UnInitObjects
'
'--------------------------------------------------------------------------
Sub UnInitObjects()

	Set SessionProc = Nothing

	Set Slide1 = Nothing

	Set Slide1EchoClients = Nothing


End Sub


'--------------------------------------------------------------------------
' Main
'
'--------------------------------------------------------------------------
Sub Main()

	CreateDefaultPort

	' Create and initialize the default context, data file,
	' and provide global access to the context.
	Dim c As Context
	Set c = New Context
	Set c.DataFile = New DataFile
	c.PushNewFrame
	Set ebContext = c

	' Set the log level names
	c.SetLogLevelName 1, "Session"
	c.SetLogLevelName 2, "Block"
	c.SetLogLevelName 3, "Trial"
	c.SetLogLevelName 4, "SubTrial"
	c.SetLogLevelName 5, "LogLevel5"
	c.SetLogLevelName 6, "LogLevel6"
	c.SetLogLevelName 7, "LogLevel7"
	c.SetLogLevelName 8, "LogLevel8"
	c.SetLogLevelName 9, "LogLevel9"
	c.SetLogLevelName 10, "LogLevel10"

	' Set standard logging items
	ebContext.SetAttrib "Experiment", "ShowRawInput (loop using Inline script)"
	ebContext.SetAttrib "SessionDate", Date$
	ebContext.SetAttrib "SessionTime", Time$
	ebContext.SetAttrib "RandomSeed", PRNG.GetSeed()

	If Basic.OS = ebWin32 Then
		WinActivate "E-Run Experiment Window"
	End If

	' Get the StartupInfo
	' Set default for GroupNumber
	c.SetAttrib "Group", "1"


	' Set the defaults for all of the StartupInfo
	c.SetAttrib "Subject", "1"
	c.SetAttrib "Session", "1"

	' Set the default Data Filename
	c.DataFile.Filename = CStr(c.GetAttrib("Experiment")) & "-" & CStr(c.GetAttrib("Subject")) & "-" & CStr(c.GetAttrib("Session")) & ".txt"
	' Initialize all system devices, packages, and objects
	InitDevices c
	InitPackages c
	InitObjects c

	' If we are logging data, then open the datafile
	If CLng(c.GetAttrib("Subject")) <> 0 Then
		c.DataFile.Open
		c.LogHeader
	End If

	' Start the running of the Experiment
	SessionProc.Run c

	' Clean up the context and close the datafile
	If CLng(c.GetAttrib("Subject")) <> 0 Then
		c.DataFile.Close
		' Attempt to convert the recovery file into a data file
		Dim nConvert As Long
		nConvert = c.DataFile.Convert(ebProgressNone)
	End If
ExperimentFinish:

	UnInitObjects

	UnInitPackages
	UnInitDevices

ExperimentAbort:

	' Clean up the context
	c.PopFrame
	Set c = Nothing
	Set ebContext = Nothing

	DestroyDefaultPort

End Sub
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ShowRawInput (loop using Inline script).es
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20080208/74885c28/attachment.ksh>
-------------- next part --------------
'
'
'
'	C:\Documents and Settings\fmri\My Documents\My Experiments\ShowRawInput\ShowRawInput (loop using List).ebs
'	Generated on: 11/27/2006	15:25:52
'
'
'	This file generated with E-Studio interface.
'	E-Prime Copyright ? 2002 Psychology Software Tools.
'	ALL RIGHTS RESERVED

'	Legal use of this experiment script requires a full E-Prime or Runtime License.
'
'
'	Author:
'		  David McFarlane (Michigan State University)
'
'
'
'

Option CStrings On
Dim ebContext as Context


'--------------------------------------------------------------------------
' Class Declarations
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
'InitSlideStateDefaults
'--------------------------------------------------------------------------
Sub InitSlideStateDefaults(theSlideState As SlideState)

	If theSlideState Is Nothing Then Exit Sub

	theSlideState.X = "center"
	theSlideState.Y = "center"
	theSlideState.Width = "100%"
	theSlideState.Height = "100%"
	theSlideState.BackColor = CColor("white")
	theSlideState.BackStyle = "opaque"
	theSlideState.BorderColor = CColor("black")
	theSlideState.BorderWidth = CLng("0")
	theSlideState.XAlign = "center"
	theSlideState.YAlign = "center"
	theSlideState.ClearAfter = CLogical("No")
	theSlideState.Enabled = CLogical("Yes")

End Sub

'--------------------------------------------------------------------------
'InitSlideVisualStimDefaults
'--------------------------------------------------------------------------
Sub InitSlideVisualStimDefaults(theSlideVisualStim As SlideVisualStim)

	If theSlideVisualStim Is Nothing Then Exit Sub

	theSlideVisualStim.X = "center"
	theSlideVisualStim.Y = "center"
	theSlideVisualStim.Width = "25%"
	theSlideVisualStim.Height = "25%"
	theSlideVisualStim.ForeColor = CColor("black")
	theSlideVisualStim.BackColor = CColor("white")
	theSlideVisualStim.BackStyle = "opaque"
	theSlideVisualStim.BorderColor = CColor("black")
	theSlideVisualStim.BorderWidth = CLng("0")
	theSlideVisualStim.XAlign = "center"
	theSlideVisualStim.YAlign = "center"
	theSlideVisualStim.AlignHorizontal = "center"
	theSlideVisualStim.AlignVertical = "center"

End Sub

'--------------------------------------------------------------------------
'InitSlideTextDefaults
'--------------------------------------------------------------------------
Sub InitSlideTextDefaults(theSlideText As SlideText)

	If theSlideText Is Nothing Then Exit Sub

	InitSlideVisualStimDefaults theSlideText

	theSlideText.WordWrap = True
	theSlideText.FontName = "Courier New"
	theSlideText.FontSize = "18"
	theSlideText.FontBold = CLogical("Yes")
	theSlideText.FontItalic = CLogical("No")
	theSlideText.FontUnderline = CLogical("No")
	theSlideText.FontStrikeout = CLogical("No")

End Sub

'--------------------------------------------------------------------------
'InitSlideImageDefaults
'--------------------------------------------------------------------------
Sub InitSlideImageDefaults(theSlideImage As SlideImage)

	If theSlideImage Is Nothing Then Exit Sub

	InitSlideVisualStimDefaults theSlideImage

	theSlideImage.Stretch = CLogical("No")
	theSlideImage.MirrorLeftRight = CLogical("No")
	theSlideImage.MirrorUpDown = CLogical("No")
	theSlideImage.UseSourceColorKey = CLogical("No")
	theSlideImage.SourceColorKey = CColor("black")

End Sub

'--------------------------------------------------------------------------
'InitSlideSoundBufferDefaults
'--------------------------------------------------------------------------
Sub InitSlideSoundBufferDefaults(theSoundBuffer As SoundBuffer)

	If theSoundBuffer Is Nothing Then Exit Sub

	theSoundBuffer.Loop = CLogical("No")
	theSoundBuffer.StopAfter = CLogical("Yes")
	theSoundBuffer.StartOffset = "0"
	theSoundBuffer.StopOffset = "0"

End Sub




'--------------------------------------------------------------------------
' Instance Declarations
'--------------------------------------------------------------------------
Dim Display As DisplayDevice
Dim Sound As SoundDevice
Dim Keyboard As KeyboardDevice
Dim Mouse As MouseDevice
Dim SRBOX As SRBOXDevice
Dim SessionProc As Procedure

Dim List1 As List

Dim Proc1 As Procedure

Dim Slide1 As Slide
Dim Slide1EchoClients As EchoClientCollection
Dim Slide1_State As SlideState
Dim Slide1_SlideText As SlideText



'--------------------------------------------------------------------------
' Package Declare Script
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' User Script
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' Package Global Script
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' Package Routines
'--------------------------------------------------------------------------



'--------------------------------------------------------------------------
' Implementation
'--------------------------------------------------------------------------
Sub SessionProc_Run(c as Context)
	List1.Run c

	c.Log
End Sub

Sub Proc1_Run(c as Context)
	
	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - SetSlide1 BEGIN
	'''''''''''''''''''''''''''''''''''''''''''''
	beep
Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects("i"))
Slide1_SlideText.Text = c.GetAttrib("List1.Sample") - 1
Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects("Response"))
Slide1_SlideText.Text = Slide1.RESP
Set Slide1_SlideText = Nothing

	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - SetSlide1 END
	'''''''''''''''''''''''''''''''''''''''''''''
	
	
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'	Label - DoSlide1 BEGIN
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

DoSlide1:
	If Err.Number = ebInputAccepted Then
		Err.Clear
		Resume DoSlide1Resume
	ElseIf Err.Number <> 0 Then
		'NOTE: If you receive a runtime error here, it
		' is because a runtime error other than ebInputAccepted
		' was thrown (ebInputAccepted for catching input masks that jump).
		'You are encouraged to either handle the error so that
		' it is not thrown in the future or will have to set up
		' your own error handler, which will also need to take
		' into account for any input masks that jump.
		'
		'Raise the error so the default error handler will show the message
		Err.Raise Err.Number
	End If

DoSlide1Resume:

	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'	Label - DoSlide1 END
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

	
	
	Select Case Slide1.ActiveState
		Case "Default"


			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(1))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(2))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(3))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(4))
			Set Slide1_SlideText = Nothing

			Set Slide1_SlideText = CSlideText(Slide1.States.Item("Default").Objects(5))
			Set Slide1_SlideText = Nothing
	End Select

	
	Slide1.InputMasks.Reset
	
	Slide1EchoClients.RemoveAll
	Slide1.InputMasks.Add Keyboard.CreateInputMask("{ANY}", "", CLng(Slide1.Duration), CLng("1"), ebEndResponseActionTerminate, CLogical("Yes"), "", "", "ResponseMode:All ProcessBackspace:Yes")

	
	Slide1EchoClients.RemoveAll
	Slide1.InputMasks.Add SRBOX.CreateInputMask("{ANY}", "", CLng(Slide1.Duration), CLng("1"), ebEndResponseActionTerminate, CLogical("Yes"), "", "", "")

	
	Slide1.Run
	
	c.SetAttrib "Slide1.RESP", Slide1.RESP
	
	
	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - ListExit BEGIN
	'''''''''''''''''''''''''''''''''''''''''''''
	' We let Slide1 time out every second or so just to catch & process any
' <ctrl><shift> user break even if Slide1 takes no keyboard input.  Then if
' Slide1 had no response we restart Slide1.  So the procedure does not end
' until we get a response to Slide1 or a user break.
if GetUserBreakState() <> 0 then List1.Terminate
if Slide1.RESP = "" then goto DoSlide1

	'''''''''''''''''''''''''''''''''''''''''''''
	' InLine - ListExit END
	'''''''''''''''''''''''''''''''''''''''''''''
	
	c.SetAttrib "Slide1.RESP", Slide1.RESP
	

	c.Log
End Sub





'--------------------------------------------------------------------------
' InitDevices
'
'--------------------------------------------------------------------------
Sub InitDevices(c As Context)



	SetOSThreadPriority 3


	Set Display = New DisplayDevice
	Display.Name = "Display"

	Dim DisplayDisplayDeviceInfo As DisplayDeviceInfo
	DisplayDisplayDeviceInfo.XRes = 640
	DisplayDisplayDeviceInfo.YRes = 480
	DisplayDisplayDeviceInfo.ColorDepth = 16
	DisplayDisplayDeviceInfo.RefreshRate = 0
	DisplayDisplayDeviceInfo.NumPages = 0

	Display.Open DisplayDisplayDeviceInfo
	c.SetAttrib "Display.RefreshRate", Format$(Display.CalculatedRefreshRate, "0.000")

	Set Sound = New SoundDevice
	Sound.Name = "Sound"

	Dim SoundSoundOutDeviceInfo As SoundDeviceInfo
	SoundSoundOutDeviceInfo.Channels = 2
	SoundSoundOutDeviceInfo.SamplesPerSecond = 22050
	SoundSoundOutDeviceInfo.BitsPerSample = 16
	
	Set Keyboard = New KeyboardDevice
	Keyboard.Name = "Keyboard"

	Dim KeyboardKeyboardDeviceInfo as KeyboardDeviceInfo
	KeyboardKeyboardDeviceInfo.CollectionMode = ebPressesAndReleases
	KeyboardKeyboardDeviceInfo.CapsLock = ebCapsLockOff
	KeyboardKeyboardDeviceInfo.NumLock = ebNumLockOn
	Keyboard.Open KeyboardKeyboardDeviceInfo
	
	Set Mouse = New MouseDevice
	Mouse.Name = "Mouse"

	Dim MouseMouseDeviceInfo as MouseDeviceInfo
	MouseMouseDeviceInfo.OpenMode = ebMouseOpenModeDirect
	MouseMouseDeviceInfo.CollectionMode = ebPressesOnly
	MouseMouseDeviceInfo.ShowCursor = False
	Mouse.Open MouseMouseDeviceInfo

	Set SRBOX = New SRBoxDevice
	SRBOX.Name = "SRBOX"

	Dim SRBOXSRBoxDeviceInfo As SRBoxDeviceInfo
	SRBOXSRBoxDeviceInfo.Model = 200
	SRBOXSRBoxDeviceInfo.Revision = 1
	SRBOXSRBoxDeviceInfo.CommPort = 1
	SRBOXSRBoxDeviceInfo.BaudRate = 19200
	SRBOXSRBoxDeviceInfo.CharacterRate = 800
	SRBOXSRBoxDeviceInfo.Configuration = ebSRBoxConfigBRUUnique
	SRBOXSRBoxDeviceInfo.CollectionMode = ebPressesAndReleases
	SRBOX.Open SRBOXSRBoxDeviceInfo


	SetOSThreadPriority 0

End Sub



'--------------------------------------------------------------------------
' InitObjects
'
'--------------------------------------------------------------------------
Sub InitObjects(c As Context)

	Set SessionProc = New Procedure
	SessionProc.Name = "SessionProc"
	SessionProc.Tag = ""
	SessionProc.Subroutine = "SessionProc_Run"

	Set List1 = New List
	List1.Name = "List1"
	List1.Tag = ""

	'Initialization for List1
	
	Set List1.Order = New SequentialOrder
	Set List1.Deletion = NoDeletion
	List1.ResetEveryRun = False

	' Create the column headings
	List1.Filename = ""
	List1.LoadMethod = ebLoadMethodEmbedded

	List1.Load

	Set List1.TerminateCondition = TimedMSecs(600000)
	Set List1.ResetCondition = Samples(1)
	List1.Reset
	
	Set Proc1 = New Procedure
	Proc1.Name = "Proc1"
	Proc1.Tag = ""
	Proc1.Subroutine = "Proc1_Run"

	Set Slide1 = New Slide
	Slide1.Name = "Slide1"
	Slide1.Tag = ""

	Set Slide1EchoClients = New EchoClientCollection
	Slide1.Duration = CLng("1000")
	Slide1.TimingMode = ebTimingModeEvent
	Slide1.PreRelease = Val("0")

	Slide1.OnsetSync = 1
	Slide1.OffsetSync = 0

	Set Slide1_State = New SlideState
	Slide1_State.Name = "Default"

	InitSlideStateDefaults Slide1_State


	Slide1.States.Add Slide1_State, "Default"


	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "Response"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = ""
	Slide1_SlideText.Y = "50%"
	Slide1_SlideText.Width = "30%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "left"
	Slide1_SlideText.AlignHorizontal = "left"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "Response"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "ResponseLabel"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = "Response = "
	Slide1_SlideText.Y = "50%"
	Slide1_SlideText.Width = "30%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "right"
	Slide1_SlideText.AlignHorizontal = "right"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "ResponseLabel"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "i"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = ""
	Slide1_SlideText.Y = "45%"
	Slide1_SlideText.Width = "10%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "left"
	Slide1_SlideText.AlignHorizontal = "left"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "i"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "iLabel"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = "# "
	Slide1_SlideText.Y = "45%"
	Slide1_SlideText.Width = "5%"
	Slide1_SlideText.Height = "5%"
	Slide1_SlideText.XAlign = "right"
	Slide1_SlideText.AlignHorizontal = "right"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "iLabel"

	Set Slide1_SlideText = New SlideText
	Slide1_SlideText.Name = "Info"

	InitSlideTextDefaults Slide1_SlideText

	Slide1_SlideText.Text = "Press any key or button to see the result below.\nPress <CTRL><SHIFT> to exit."
	Slide1_SlideText.Y = "25%"
	Slide1_SlideText.Width = "80%"
	Slide1_SlideText.Height = "15%"
	Slide1.States.Item("Default").Objects.Add Slide1_SlideText, "Info"
	Slide1.ActiveState = "Default"


End Sub


'--------------------------------------------------------------------------
' InitPackages
'
'--------------------------------------------------------------------------
Sub InitPackages(c As Context)

End Sub



'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
' UnInitDevices
'--------------------------------------------------------------------------
Sub UnInitDevices()
	Display.Close
	Set Display = Nothing

	Keyboard.Close
	Set Keyboard = Nothing

	Mouse.Close
	Set Mouse = Nothing


	SRBOX.Close
	Set SRBOX = Nothing

End Sub


'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
' UnInitPackages
'--------------------------------------------------------------------------
Sub UnInitPackages()
End Sub


'--------------------------------------------------------------------------
' UnInitObjects
'
'--------------------------------------------------------------------------
Sub UnInitObjects()

	Set SessionProc = Nothing

	Set List1 = Nothing

	Set Proc1 = Nothing

	Set Slide1 = Nothing

	Set Slide1EchoClients = Nothing


End Sub


'--------------------------------------------------------------------------
' Main
'
'--------------------------------------------------------------------------
Sub Main()

	CreateDefaultPort

	' Create and initialize the default context, data file,
	' and provide global access to the context.
	Dim c As Context
	Set c = New Context
	Set c.DataFile = New DataFile
	c.PushNewFrame
	Set ebContext = c

	' Set the log level names
	c.SetLogLevelName 1, "Session"
	c.SetLogLevelName 2, "Block"
	c.SetLogLevelName 3, "Trial"
	c.SetLogLevelName 4, "SubTrial"
	c.SetLogLevelName 5, "LogLevel5"
	c.SetLogLevelName 6, "LogLevel6"
	c.SetLogLevelName 7, "LogLevel7"
	c.SetLogLevelName 8, "LogLevel8"
	c.SetLogLevelName 9, "LogLevel9"
	c.SetLogLevelName 10, "LogLevel10"

	' Set standard logging items
	ebContext.SetAttrib "Experiment", "ShowRawInput (loop using List)"
	ebContext.SetAttrib "SessionDate", Date$
	ebContext.SetAttrib "SessionTime", Time$
	ebContext.SetAttrib "RandomSeed", PRNG.GetSeed()

	If Basic.OS = ebWin32 Then
		WinActivate "E-Run Experiment Window"
	End If

	' Get the StartupInfo
	' Set default for GroupNumber
	c.SetAttrib "Group", "1"


	' Set the defaults for all of the StartupInfo
	c.SetAttrib "Subject", "1"
	c.SetAttrib "Session", "1"

	' Set the default Data Filename
	c.DataFile.Filename = CStr(c.GetAttrib("Experiment")) & "-" & CStr(c.GetAttrib("Subject")) & "-" & CStr(c.GetAttrib("Session")) & ".txt"
	' Initialize all system devices, packages, and objects
	InitDevices c
	InitPackages c
	InitObjects c

	' If we are logging data, then open the datafile
	If CLng(c.GetAttrib("Subject")) <> 0 Then
		c.DataFile.Open
		c.LogHeader
	End If

	' Start the running of the Experiment
	SessionProc.Run c

	' Clean up the context and close the datafile
	If CLng(c.GetAttrib("Subject")) <> 0 Then
		c.DataFile.Close
		' Attempt to convert the recovery file into a data file
		Dim nConvert As Long
		nConvert = c.DataFile.Convert(ebProgressNone)
	End If
ExperimentFinish:

	UnInitObjects

	UnInitPackages
	UnInitDevices

ExperimentAbort:

	' Clean up the context
	c.PopFrame
	Set c = Nothing
	Set ebContext = Nothing

	DestroyDefaultPort

End Sub


[DataSection_List1(1)]
Weight	Nested	Procedure
1		Proc1\0
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ShowRawInput (loop using List).es
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20080208/74885c28/attachment-0001.ksh>
-------------- next part --------------
---
David McFarlane, Systems Designer
Dept. Psychology, Michigan State University
mcfarla9 at msu.edu    www.msu.edu/~mcfarla9
Voice: (517) 353-0799    Fax: (517) 353-1652


More information about the Eprime mailing list