| Reference | Downloads | Github

continueRountine JS function

URL of experiment:

Description of the problem:

I have a loop which I run 8 times. Within that loop I have a couple of routines which I only want to run on certain instances of the loop.

The first one of these I only want to run on the 4th loop. To achieve this I create a counter earlier in the loop which increases by one with every loop. Converting from Psychopy to PsychoJS format I originally put the following code in the Begin Routine section:

if(env_counter !== 4)
countinueRoutine = false;

The routine runs on every loop, rather than just the 4th. Having searched the forum I saw that a difference between psychopy and psychoJS is that this should be in the Each Frame section of the code component for psychoJS. However, when I move it to this section, it still runs the routine on every loop.


Thanks @Anthony, this issue is probably related to the spelling error in your countinueRoutine variable. For this to work, you should try:

if(env_counter !== 4)
    continueRoutine = false;

I am such an idiot, sorry @dvbridges!

No problem, a fresh set of eyes is useful for small typos like this