Hi,
I am trying to do an EEG decision making experiment with two options. When the participant press left, one picture is loaded showing one green arrow on the left and a red arrow on the right and if the participant press right, it is the opposite, so I ask E-prime to load other picture, where the right arrow is green and the left arrow is red.
As the picture depends on the participant response, I am not using lists or c.getattrib so I tried to use a conditional load image. (if left, load and copy left stim, if right, load and copy right stim).
I am able to compile the experiment and also run it but after some successful trials (sometimes 40 trials, sometimes, 60, sometimes, 20) it crashes and error 91 appears.
It says: value of the object variable has not been set or is invalid.
I don't know what to do as I set the values and I guess the object is valid (specially because I declared it before and it is compiling and running, at least for a while).
This is the code:
'Declare variables
Dim Playcard As SlideState
Dim cnvs As Canvas
Dim lngth As Integer
Dim x, y, i As Integer
Dim source As Rect
Dim Destine As rect
Dim ArrowLeft As Canvas
Dim ArrowRight As Canvas
'Create variables
Set cnvs = Display.Canvas
Set ArrowLeft = Display.CreateCanvas
Set ArrowRight = Display.CreateCanvas
cnvs.FillColor = CColor("silver")
cnvs.clear
x=905'469 increase x value=more right
y=485'336 'increase the y value=nearer to the bottom
'Define the source rectangle
source.Left = 0
source.Right = 57 'decrease value=decrease offscreen
source.Top = 0
source.Bottom = 180 ' 155 increased values mean decrease picture in y
'Define the destine rectangle
destine.Left = x
destine.Right = 903+56
destine.Top = y
destine.Bottom = 485+162 'decreased values means decreased pictures in y
cnvs.FillColor = CColor("silver")
'Load the image to offscreen canvas
If RESPONSE.RESP = "a" Then
'Triggers (response choice left = trigger 1)
Writeport &HD050, 1
ArrowLeft.LoadImage "leftsmaller.gif"
cnvs.Copy ArrowLeft, source, destine
Set Playcard = RESPONSE.States (RESPONSE.ActiveState)
Sleep (962)
ElseIf RESPONSE.RESP = "l" Then
'Triggers (response choice right = trigger 2)
Writeport &HD050, 2
ArrowRight.LoadImage "rightsmaller.gif"
cnvs.Copy ArrowRight, source, destine
Set Playcard = RESPONSE.States (RESPONSE.ActiveState)
Sleep (962)
End If
sleep 5
writeport &HD050, 0
sleep 5
I've already tried to change the picture to bmp, tried to put load image before if/else, tried to redo the experiment in a different folder, tried to use others pictures but I still don't figure it out why it is crashing.
Also, I tried to give up the canvas copy and draw the two arrows (green for left and red for right or the opposite) and the experiment stopped crashing. However, one of the arrows is being drawn before the other (some ms before) and as I need it synchronized for the EEG, I gave up this solution too.
Any ideas about what is happening?
Thank you.
Best regards,