ReferenceError: thisN is not defined

I am trying to code an experiment with two blocks using the same routine that includes a progress bar that should track progress within the block.

Inside the progress bar routine I set progress to thisN/trialNumPerBlock, which works locally but not online. My loops are called trialsBlock1 and trialsBlock2.

Online I get the following error:

ReferenceError: thisN is not defined

I also tried trials.thisN but this doesn’t work either. When using this I get this error

ReferenceError: trials is not defined

When trying to find information on this also the discussion are on very old versions of PsychoPy. I am using v2024.2.1.

As it turns out trialsBlock1.thisN works but fortunately this means that I can’t re-use the same routine.

I solved this via adding a code routine.


if block == 1:
    trialInBlock = trialsBlock1.thisN
else:
    trialInBlock = trialsBlock2.thisN