Error saying I haven't defined a variable on the line I'm defining it?

URL of experiment: Sign in · GitLab

Description of the problem: I’m getting an error when I try to pilot the study online that says I haven’t defined a variable and points me to the line in the code where I define it (see screenshot below). It did this a couple times before, but for arrays, so I just defined the array as x = [] (for example) earlier in the code. It’s worked on builder every time I’ve had to go back and define the array earlier because of the online error. But now it’s happening with a number?? That can’t be right, right?

I also don’t know what’s happening in that for statement. Is that related? In the Py code it’s for stimName in stimNames.

Thanks in advance!

Did you end up resolving this? I am getting the error that I’m not defining the number of trials when I get to trials. This used to run a couple months ago and I wanted to make a couple modifications but for some reason it’s not running anymore. Here is my file
SpatialMem101220.psyexp (94.2 KB)

It does work now, but I’m not 100% sure what actually fixed this particular issue. I think it had to do where/when I was defining the variables. If you define the variables within a function, they don’t transfer to other functions (local variables). You have to make sure you’re defining the variables right before you need them. So here, I defined s right before the for loop and then it recognized s within the loop. It still doesn’t make complete sense to me because which variables it did this to seemed totally random, but every time this happened to a new variable, I just defined it earlier and it worked. Hope this helps at least a little… Good luck!

1 Like

Thank you so much! I’ll try the same