Routine initialized before loop is, causing NameError for condition file values

OS (e.g. Win10): MacOS Monterey 12.3.1
PsychoPy version (e.g. 1.84.x): 2023.2.3
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?: I’m building a new project that includes a routine intended to display text from a condition file on each loop. However I keep getting a NameError about the condition file parameter I’m trying to access. Just to isolate what’s going on, I made a very simple experiment with one routine and a loop around that.

Within the condition file I have two parameters, var1 and var2.

I’m trying to make the routine display values from var1 on each loop in a text component.

However running this simple study still gives a ‘NameError: name ‘var1’ is not defined’. I looked into the Python code generated by the Builder, and noticed that the initialization of components for the routine (where the ‘var1’ value is accessed) happens before the loop handler is set up (where the condition file params are added to the global name space).

Am I using the Builder incorrectly to cause this? In the Stroop demo files, the routine initialization comes after to loop handler. I can manually move the code chunk for the routine to make it work in my task, but obviously that’s cumbersome every time the Python file recompiles.

Thanks for the help!

Hello

you need to set set every repeat instead of constant

1 Like

Aha I knew it was going to be an obvious user error, thanks very much!