Help with E-Basic Mouse-Capture Loop

Tyler tybeet at gmail.com
Mon Dec 13 15:57:14 UTC 2010


I have two questions that I hope someone can help me figure out the
answers to.

I'm trying to present a Likert scale on the screen using a Slide and
capture responses using E-Basic. I have working code for this, based
on an example I found on the PST forums. The first issue I am having
is what to do when the user clicks an object that doesn't register as
a scale response. Initially, the code I was using would simply
continue and register the rating as "nothing". However, as I require a
response, I simply used an If... condition that would jump back to a
Label (and start the trial over) unless it was a registered response.
This is the code I have:

------------- BEGIN CODE

'Designate "theState" as the Default Slide State, which is the
'current ActiveState on the Slide object "Stimulus".
Dim theState As SlideState
Set theState = F1DStimulus.States("Default")

Dim theSlideText As SlideText

Dim strHit As String
Dim intRating As Integer
Dim theMouseResponseData As MouseResponseData


	'Get the mouse response.
	Set theMouseResponseData =
CMouseResponseData(F1DStimulus.InputMasks.Responses(1))

	'Was there a response?
	If F1DStimulus.InputMasks.Responses.Count > 0 Then

		'Determine string name of SlideText object at
		'mouse click coordinates. Assign that value to strHit
		strHit = theState.HitTest(theMouseResponseData.CursorX,
theMouseResponseData.CursorY)

		'Did the subject click one of the SlideText sub-objects?
		If strHit <> "" And strHit <> "Question" And strHit <> "Image" And
strHit <> "Instr" Then

			'Gain access to the SlideText sub-object selected
			'Change appearance of selected sub-object to provide feedback to
the subject.
			Set theSlideText =
CSlideText(F1DStimulus.States.Item("Default").Objects(strHit))
			theSlideText.BackColor = CColor("red")

			'Redraw the Slide to present changes
			F1DStimulus.Draw

			'Each SlideText is named "Text" followed by a single digit. The Mid
function is
			'instructed to return the 5th character (i.e. the digit) of strHit
for logging purposes.
			intRating = CInt(Mid(strHit, 5, 1))

			'Log rating in the data file under the attribute "Rating"
			c.SetAttrib "F1DRating", intRating

			Sleep 1000
			theSlideText.BackColor = CColor("gray")

		'The subject did not click a valid sub-object.
		Else
			'Restart the trial
			GoTo F1DTLabel
		End If

	'The subject did not respond.
	Else
		'Restart the trial
		GoTo F1DTLabel
	End If

Set theMouseResponseData = Nothing
Mouse.ShowCursor FALSE

------------- END CODE

The above code works flawlessly.

The problem I am having now is that I would like to use a Do... Loop
Until in place of the GoTo Label command. With the following code in
place, clicking on a scale position work, but clicking on an invalid
object does not. What happens is that the program fails to capture any
mouse clicks beyond the first one. This is the code I am using:

------------- BEGIN CODE

'This file has been modified by Tyler Burleigh - December 11, 2010

'Designate "theState" as the Default Slide State, which is the
'current ActiveState on the Slide object "Stimulus".
Dim theState As SlideState
Set theState = F1AStimulus.States("Default")

Dim theSlideText As SlideText

Dim strHit As String
Dim intRating As Integer
Dim theMouseResponseData As MouseResponseData

Do
	'Get the mouse response.
	Set theMouseResponseData =
CMouseResponseData(F1AStimulus.InputMasks.Responses(1))

	'Was there a response?
	If F1AStimulus.InputMasks.Responses.Count > 0 Then

		'Determine string name of SlideText object at
		'mouse click coordinates. Assign that value to strHit
		strHit = theState.HitTest(theMouseResponseData.CursorX,
theMouseResponseData.CursorY)

		'Did the subject click one of the SlideText sub-objects?
		If strHit <> "" And strHit <> "Question" And strHit <> "Image" And
strHit <> "Instr" Then

			'Gain access to the SlideText sub-object selected
			'Change appearance of selected sub-object to provide feedback to
the subject.
			Set theSlideText =
CSlideText(F1AStimulus.States.Item("Default").Objects(strHit))
			theSlideText.BackColor = CColor("red")

			'Redraw the Slide to present changes
			F1AStimulus.Draw

			'Each SlideText is named "Text" followed by a single digit. The Mid
function is
			'instructed to return the 5th character (i.e. the digit) of strHit
for logging purposes.
			intRating = CInt(Mid(strHit, 5, 1))

			'Log rating in the data file under the attribute "Rating"
			c.SetAttrib "F1ARating", intRating

			Sleep 1000
			theSlideText.BackColor = CColor("gray")

		End If
	End If

Loop Until (intRating > 0)

Set theMouseResponseData = Nothing
Mouse.ShowCursor FALSE

------------- END CODE

Can someone help me identify what may be causing the program to not
register new mouse clicks? I think it's something simple such as a
value not being re-set somewhere, however I tried placing Set
theMouseResponseData = Nothing and intRating = 0 inside the loop
without any luck.

Second, is it possible for the E-Basic code to "know" (or read-in) the
name of the Procedure it is running? In the code I am working with I
need to make 100+ procedures and adapt the code for each (changing,
for example, F1AStimulus to F1DStimulus), but it would save me
countless hours if I could read in this value. Is this possible?

Thanks,
Tyler

-- 
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