ReferenceError related to a variable in my xlsx condition file

URL of experiment:

Description of the problem:
I am calling an excel file containing info, word stimuli etc… in one of my loops (‘training_loop’).
I am using one of the variables from the file (‘task_tr’) to set some conditions by simply calling it inside the if-statements in the ‘code_for_trials’ routine.
(This routine is inside the loop that calls the excel file)

However, when I pilot the task online I get the error:
"ReferenceError: task_tr is not defined"

And if I try to solve this by initialising the variable at the beginning of the experiment, the error disappears but the variable is not updated according to the values in the excel file (therefore the code does not do what I want)

I find this weird because in a previous version of this task (same code, same psychopy version) I was calling file variables in the same way and everything was working correctly. This time I just edited the if-statements in the ‘code_for_trials’ routine but they should still work similarly. I guess the problem lays there somewhere but I don’t know how to solve it.

Any help would be greatly appreciated. Thank you in advance!


Variables set by spreadsheets should not be set or edited in your code.

If you need to change the value, copy it to a new variable and edit that.

Thank you for your reply.
Indeed I only tried to initialise the variable to try and fix the reference error problem, but I kind of knew it wasn’t the solution (since other spreadsheet variables don’t need to be initialised in order to work).
But the problem with the reference error remains, because I am not trying to edit that variable, I am only using it to edit other variables that I create in psychopy

instr_block1 = 0 (var created by me)

if task_tr == 1: (var from the spreadsheet)
instr_block1 = 1

that’s all I’m trying to do, I did it previously with other spreadsheet variables so I was quite sure this was ok, but now I get the error…

What tab is this in? If needs to be in Begin or End Routine within the loop not, for example, in Begin Experiment