Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

nested loop problem

PiaPia Posts: 28
edited April 10 in OpenSesame

edit: Solved it with just nesting the variables inside each other: file="[color_of_draw[jar_nr]].png"

Hi everyone,

first of all thanks for OpenSesame. I would like to build the following experiment and have a (hopefully little) problem with it:

First, I show participants the contents of a jar (red or blue marbles). Then I show them individual marbles and they have to indicate whether they think the marble comes out of the jar which they have been shown.

So therefore I have two loops. One indicating the jar (jar1, jar2, jar3,…) which the participants are shown in the beginning and then a loop for the presentation of the individual marbles (for jar1: red, blue, blue, blue,…., for jar2: red, red, red, blue,…. and so on).

Now the problem is I managed to set up both loops individually but not together.

Like, if I just want to set up the loop where the participants are shown individual marbles, I have a variable [color_of_draw] which contains the sequence (red, blue, blue, …) and then the images (red.png or blue.png) are shown like defined.

If I just want to show the jars, I define a variable [jar] in that loop which contains jar1, jar2, etc. and then I show the corresponding picture (like jar1.png).

But now I want to fit my loop of the single draws/marbles into the higher order loop of different jars. But then I can’t use my variable [color_of_draw] anymore because the color of the draw depends on the jar.

I tried to build different variables like jar1, jar2, jar3 instead of color_of_draw and put the order of the red and blue draws in the different lines, but the problem is, I can’t load the image jar[jar].png (where [jar] indicates which jar the marble is out of) at this place because it is called blue.png.

Any suggestion on how to solve this problem is appreciated!

Thank you!


  • sebastiaansebastiaan Posts: 2,594

    edit: Solved it with just nesting the variables inside each other: file="[color_of_draw[jar_nr]].png"

    Great, and thanks for letting us know!

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.

Sign In or Register to comment.