| Reference | Downloads | Github

Can't exit loop

URL of project:

Description of the problem:

I am trying to end two loops at the end of the experiment by using the loop.finished = true; syntax. I have a counter which, when it reaches 8, should break out of the loops with the following code:

if(env_counter == 8)
    uber_order.finished = true;
    order.finished = true;

However, the loop continues. The counter appears to be working, because other routines are being initiated properly based on its number. I originally had this code in End Routine, but moved it to Each Frame in case that was the problem. Then, based on other answers to similar questions I tried ticking isTrials for both loops, but then it exits the loop after one iteration - I’m not sure why but either way this solution doesn’t seem to work for my case.

Any help would be greatly appreciated. The code in question comes in the ‘end’ routine at the end of the experiment. This should be the last hurdle before getting this task online!


1 Like

I have exactly the same problem. Have you solved it, Anthony?

My experiment works perfectly on my desktop but the following loop seems not working online. The loop continues whatsoever.

if number_correct == 3:
NoPass.finished = True
NoPass.finished = False

I wanted to leave the link here, but am experiencing another issue: the experiment status is PILOTING but the pilot token is missing from the URL

Any help would be great. Thanks!

Hi @Hana_Jee,

I actually can’t remember how I solved this to be honest. However, the code in your question is written in python - it needs to be in JS for the online version. So yours would be:

if (number_correct == 3)
NoPass.finished = true;
} else
NoPass.finished = false