Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Custom Feedback

edited March 2015 in OpenSesame

Hi all!

I am very new to both OpenSesame and Phyton, so sorry in advance if the question is either silly or already solved.

I've successfully created the variable X via in-line script. The variable X does everything I need, and the experiment works fine - all the variables are well logged and so on... Variable X changes at every trial accordingly to the performance of the subject. X is an integer, not a float or string type.

But you know, sometimes you may want to add 'classy' details.

Once in a while I let the participants take a break. During breaks I would like to show them a lot of text, just to keep in mind the instructions, but also the value of the variable X. I use a text_display object.

Putting [X] in the text does not work.

Despite X is continuosly setted and changed during the procedure ( exp.set('X', X) ), the only value [X] gives is 0, namely the initial value of X. I tried Phyton language into the text but it is read as a string.

Variable X, in the log file, is fine instead.

What am I missing?

Thanks a lot for your work and attention!


  • edited 3:12AM

    Hi Elvio,

    It seems that you're doing things correctly. If you have Python variable x, which lives in your inline_script items, you need to use exp.set('x', x) to create an experimental variable that has the same name and value. Once you've done that you can refer to this variable throughout OpenSesame, using the square-bracket notation ([x]). See also:

    One thing that comes to mind is that you may be exp.setting the variable too late. For example, if you set the variable during the run phase, it won't be available in sketchpads, because these are prepared in advance, during the prepare phase. For more information, see:

    Also, it won't hurt to print a little information to the debug window, to make sure that x really has the correct value. Like so:

    print('X = %s' % x)
    exp.set('x', x)


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

  • edited 3:12AM

    I see... Thanks for your hint, I will try with a feedback object instead of a sketchpad one. :D

  • edited 3:12AM

    It works!

    Indeed, now that i look at the script I see that sketchpads, also the ones outside a sequence, are prepared in advance; at the beginning the value of X was 0, so it all makes sense.

    The feedback object works fine and reads the last value of X.

    Thanks a lot!

Sign In or Register to comment.