[solved] Why can't I break a loop... :(
I still can't break my loop. I want it to be possible when participants press ''9'' that they can stop the loop. How is this possible? I want to use the break if statement in a loop.
To make it easy to understand this, this is my experiment:
https://www.dropbox.com/s/hlkryjb4h7fbzhd/paardentaak.opensesame.tar.gz?dl=0
Please I could use some help
Comments
Hi Vindicare,
I took some time to look at your experiment.
The problem: in your loop item, you named one of your variables 'response', which was set to either h, b, g or l in every trial. Hence, if you use the command 'break if [response] = q', you will never break since this condition doesn't occur. I think you meant to name the variable 'correct_response' instead.
By doing so, the variable 'response' will be made by the keyboard item instead. The last thing we need to do is create the variable 'response' BEFORE the loop, since otherwise you get an error when you enter the loop for the first time. To do this, you can simply drag an inline_script item to the top of the 'experiment' sequence in the overview window, and insert the line: "exp.response = False" (without quotation marks). This creates the response variable and adds the value False to it (you could give it any other value of course). The value is changed with every next button response, meaning you will now succesfully break when the given response was a 'q'.
Good luck!
Cheers,
Josh