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

Extracting an item from list and displaying it as text in a sketchpad

GiorgioAlfaGiorgioAlfa Posts: 3
edited March 16 in OpenSesame

Dear Opensesame people,

I'm building a simple experiment in Opensesame and I'm stuck on a problem which has something to do with how the sketchpad script is structured by default.
My task is a version of the n-back in which items (caps lock letters) are presented one at a time. The number of letters in this study list must be random between 6 and 12, and I create the list at the beginning of the trial in an inline object. Then I call each single item of the list one at a time in a series of sketchpad in the sequence.

When I try to show the items calling them in the script where the text is suposed to be, the indication is shown in the slide as a text itself and it doesn't call the item from the list: as an example, I read [studylist[-itemnumber]] instead of C.
I tried to remove the inverted commas, but it looks like they are just a default thing in the text section of sketchpad function in Opensesame.

draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always **text="[studylist[-12]]"** x=0 y=0 z_index=0

Any ideas?
Thank you in advance :)



  • sebastiaansebastiaan Posts: 2,516

    Hi Giorgio,

    The standard [variable_name] notation does not allow you to do anything except refer to a variable. If you want to do more, you can embed arbitrary Python code using [=python_code] notation.

    In your case, the following would seem to work:


    Note that the square brackets in the code need to be escaped (\[ and \]).

    See also:


    Thanked by 1GiorgioAlfa

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

  • Hi Sebastian :)
    Thank you very much, the problem was that the square brackets were not escaped!
    Sorry, maybe it is probably something I would have been aware of if I was more practical with python programming in general?

  • dsilva.maridsilva.mari Posts: 10

    I have a somewhat similar problem - I made a sketchpad and displayed 12 letters in it. The user should be able to click on however many letters he wants and should be able to see his selections on the screen. I stored the selections in an array, and then made the array into a string, and tried to display the variable on the sketchpad, but I get an error saying that the variable does not exist. Any ideas?


    Mariana .

  • I think Opensesame generates the sketchpad script in the "preparation" phase before start running the actual sequence. If the array is actually generated DURING the sequence, then the sketchpad will not be able to find the array in the preparation phase. Have you tried to embed the array code in the preparation phase? You can do it with an inline object, writing the code in the "prep" sheet!

  • dsilva.maridsilva.mari Posts: 10

    Hi Giorgio! Using a sketchpad item wasn't doing the trick for me ( even if I defined the variable in the preparation phase) , so I ended up using widgets and creating a form -- I defined a variable to the beginning of the experiment and managed to add the letters that the user clicked on, and then displayed it with a custom widget that returns user input.

  • JarikJarik Posts: 170


    Maybe using a feedback item also helps (for future experiments):


Sign In or Register to comment.