[solved] Count number of times something happens in a while loop
Hi all,
I have a while loop with two if statements written in an inline script. I would like to count how many times each if statement is used through the course of the experiment.
The if statements each evaluate whether a mouse click occurs within a specified area (within a green circle or within a white circle), so there isn't a correct type variable, only sets of coordinates. I could record the coordinates, but then later I would have to figure whether those coordinates were for the white or the green circle.
I'm thinking there should be a way to add a count function to each of the if statements, but I'm not having any luck.

Comments
Hi Darby,
I'm assuming you're working with a script from the discussion below, or some variation of it, but the basic principle should work anywhere.
What you could do is use a variable
nClickErrthat is incremented (+= 1) every time that an erroneous click is registered. This will give you a running total of the number of times that this happens during the entire experiment. Just read the code below carefully, and the logic should be clear (it's pretty simple).Is this what you had in mind?
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks so much Sebastiaan. As usual, this works great.