continueRoutine = False Problem, although it is in Each Frame

Here is the code from my dev tools. I also included screenshots if that helps…

core-2020.2.js:1822 ReferenceError: idx is not defined
    at Scheduler._currentTask (TCALL_100520.js:4604)
    at Scheduler._runNextTasks (util-2020.2.js:1560)
    at Scheduler._runNextTasks (util-2020.2.js:1564)
    at Scheduler._runNextTasks (util-2020.2.js:1564)
    at update (util-2020.2.js:1517)
window.onerror @ core-2020.2.js:1822
log4javascript.min.js:1 FATAL unknown | {}
BrowserConsoleAppender.append @ log4javascript.min.js:1
core-2020.2.js:721

dev tools screen shot

ref error

ah I think it is because I did not capitalize Idx in the console line. Ugh OK trying again for you!

1 Like

Ok I have dev tools open. I ran it again and again the pause routine did not conditionally end after the 3rd iteration of the loop. Bear with me as I have only inspected dev tools a handful of other times. I have it open. What should I do now?

You don’t need continueRoutine = True, since that’s the default.

You could try

if Idx > 1:
     continueRoutine = False

Just tried that and it made it so the LRpause routine never comes up (regardless of LRblock iteration). The code in LRpause now looks like this:

console.log(Idx)
if Idx > 1:
    continueRoutine = False

That sounds like Idx is already greater than 1. What value was in the console? (Under info) Are you using Idx for anything else (e.g. a loop)?

That’s exactly what I was thinking. I am not using Idx for anything else. It is initialized at beginning of experiment, set to Idx +=1 at the end of the loop and then the if statement is called during the LRpause component. I set Idx > 3 and am trying now. Unfortunately, I did not check the value in the console the last time and I reset cache. So sorry about that. Thanks for being patient with me. I am trying again now.

Ok even when Idx >3, the LRpause component never continued (always skipped it). I don’t see an exact value under info in the console but I am prob looking in wrong place. This is what I see in the console when I filter info only:

If I click on the first line (because the 2nd and 3rd line are only there because I prematurely ended the experiment when I realized the LRpause routine was skipped incorrectly), I get a longer script but no value printed to console…

That value of 36 might be Idx

I’d recommend changing it to a different variable name (e.g. loopIdx )

You can console log using print(‘Idx: ‘+Idx) (use simple quotes) to be sure

I’m wondering whether you are incrementing Idx in an earlier loop. Should it reach 36 at some point?

I have no value of Idx in any other loop. I first used it when you recommended! Interesting…I’ll try using the different name as you suggested. With that said, 36 is the number of trials per loop. Maybe it is confusing the LRtrials with LRblock? Should I put the Idx+= OUTSIDE of the inner loop maybe?

If you have concentric loops then you need to increment Idx in the outer loop not the inner one if you want it to count the outer loop only.

Alternatively you could say if Idx > 70 if you want it to be true after the second repeat of the inner loop

1 Like

ah duh! SUCCESS! Since I wanted it to be true (aka continueRoutine = False) after the third repeat, I set Idx > 105 (because I have 36 trials per loop and the counter starts at 0 so 35 x 3 = 105) and it worked!

I think some things were lost in my translation above and that is why I originally set it Idx >3 in the inner loop. As you said, I could have put Idx >3 in the outer loop and probably have the same effect.

Thanks so much @wakecarter and @Becca. This is a great alternative to .thisN when using Pavlovia.

Take care,
Maya

Hi everyone,

I am having a similar problem to the ones discussed above in my Pavlovia experiment. I have a code component with continueRoutine = False depending on a variable in my conditions excel file, so that it skips the routines introduce1 and introduce2 when specified in the excel files as “FALSE”.

Here is what my experiment looks like on builder:

In my code component of the routines introduce1 and introduce2 I have this (in Every Frame):

if intro=="FALSE":
    continueRoutine=False
if intro=="TRUE":
    continueRoutine=True

and in my inner loop (trials) I have this:image

And here’s a snapshot of my excel file with the column “intro” specifying when introduce1 and introduce2 should and should not play:

This works well in Psychopy, as it skips introduce1 and introduce2 on the trials I specified in the excel file. However, when I move my experiment to pavlovia I get this:
image

This is my first time using Psychopy and Pavlovia, so any ideas about how to fix this or what I could do differently would be greatly appreciated!

Thanks in advance!

Rina

Do you want TRUE and FALSE to be interpreted as numbers? If so, then you shouldn’t have quotes round them. If not, then nReps = intro doesn’t make sense. Off the top of my head I’m not sure whether TRUE and FALSE work the same as True and False.

Also, remove the second if statement. continueRoutine=True is the default.

Thank you! It seems that removing the continueRoutine=True fixed the problem!