use mouse as response device for visual analog scales

Carol cm396j at nih.gov
Tue Jun 29 22:09:46 UTC 2010


I don't know much about writing programs and have run into a big snag.
I have an eprime file written to use a joystick type device and I want
to revise the program to use a mouse instead. Something like, hold the
left mouse button down to scroll across a line (visual analog scale)
and the right mouse button to select the desired spot along the line.
Here are the two scripts, not sure if both need to be revised.... I
would be forever grateful if someone can help me with this.

1st script:
ZeroWheel
Pos = 400
PrevPos = -1
MaxPos = 400
MinPos = -400

'Draw main bar
cnvs.PenWidth = 1
cnvs.PenColor = CColor("blue")
cnvs.FillColor = CColor("blue")
cnvs.Rectangle 110, 350, 804, 40

'Draw box around the bar that they have to move out of
cnvs.PenWidth = 5
cnvs.PenColor = CColor("black")
cnvs.line 503, 330, 503, 409
cnvs.line 504, 330, 520, 330
cnvs.line 521, 330, 521, 409
cnvs.line 504, 410, 520, 410
moved = FALSE

'get the scale from the list
xscale = c.getattrib("scale")
xdivisor = c.getattrib("divisor")

'start the timer
starttime = Clock.Read

2nd script:
Dim x as long
Dim b as long
Dim err1 as integer


'Get New pos
err1 = ReadWheel(x,b,FALSE)
if (err1 = -1) then
	Debug.Print "Died with err1 = -1"
	Questions.terminate
End if

x = Cint(x/xdivisor) * xscale
if (x < MinPos) then
	MinPos = x
	MaxPos = MinPos + 800
	Pos = 800
elseif (x > MaxPos) then
	MaxPos = x
	MinPos = MaxPos - 800
	Pos = 0
else
	Pos = MaxPos - x
End if

if (Pos <> PrevPos) Then
	cnvs.PenWidth = 1

	'is this the first move? if so erase the box
	if (Not moved) AND Pos <> 400 then
		moved = TRUE
		cnvs.PenColor = CColor("white")
		cnvs.FillColor = CColor("white")
		cnvs.rectangle 500, 327, 28, 23
		cnvs.rectangle 500, 390, 28, 23
		cnvs.PenColor = CColor("blue")
		cnvs.FillColor = CColor("blue")
		cnvs.rectangle 500, 350, 28, 40
	end if

	'Erase old tab
	cnvs.PenColor = CColor("blue")
	cnvs.FillColor = CColor("blue")
	cnvs.Rectangle 110+PrevPos, 350, 5, 40
	cnvs.PenColor = CColor("white")
	cnvs.FillColor = CColor("white")
	cnvs.Rectangle 110+PrevPos, 340, 5, 10
	cnvs.Rectangle 110+PrevPos, 390, 5, 10
	'Draw New Tab
	cnvs.PenColor = CColor("black")
	cnvs.FillColor = CColor("black")
	cnvs.Rectangle 110+Pos, 340, 5, 60
	PrevPos = Pos
End if

'timed out with no button press
if ((b = 0) AND (Clock.Read - starttime) >
CLng(c.getattrib("duration"))) then
	c.setattrib "wheelpos", -1*pos
	c.setattrib "responsetime", starttime-Clock.Read
	goto timeout
End if

'no button press, so end
if (b = 0) then
	goto loopstart
End if

'pushed button, but no move (bastard)
if (b <> 0) AND NOT moved then
	goto loopstart
End if

'pushed a button, so we are done
c.setattrib "wheelpos", pos
c.setattrib "responsetime", Clock.Read - starttime

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