Error when importing conditions in nested loops

Not quite - but your comment led me to what was going on, and to the following generalisation:

You can modify the value of variable imported from a conditions file in PsychoPy without issue, but if you do so in PsychoJS, this will cause the variable to be automatically defined without a value in the script, and so undefined when you try to use it.

So I was modifying my TARGET variable, read in from the conditions file, depending on a particular condition; specifically, to swap 0 to 1 and v/v.
TARGET = abs(TARGET - 1)

This left TARGET still usable (defined) in PsychoPy, but in PsychoJS, this causes the script that gets built to add the line (outside any loop or function):
var TARGET;

So when I get to using TARGET, it is no longer defined for the value read in from the conditions file----at least in PsychoJS; in PsychoPy, without imposing this initial declaration, there’s no issue.

Changing the value of the modification, above, to thisTARGET, and always using that instead of TARGET, now gets it all going (for now).

Is this a bug–incompatibility between what you can do in PsychoPy but not PsychoJS?

Thanks for your pointer about there being a conflict like this at the root of the problem.

1 Like