Howdy, Stranger!

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

Supported by

Error while executing inline script

Hello all!

I am getting the following error when I try to run the experiment.
The weird thing is that it only happens sometimes. Other times the experiment works completely fine. Any ideas?

Also, this is the inline script it is referring to:
#Increase total reward by amount of reward for that trial. Run only if [correct]=1 var.total_reward = var.total_reward + var.reward_value


  • edited November 2017

    Hey tnells,

    I assume var.total_reward and var.reward_value are both supposed to be floats or integers but judging from the error output one of them isn't. Maybe you can print the variables or check their type() while running your experiment to see which one.
    The reason why it sometimes work and sometimes doesn't may have to do with how you update the variables. Printing how the values change from trial to trial should also give you a clue under which conditions they turn into unicode.


  • Hi Michif,

    Thanks so much for your prompt response. I've been looking on OpenSesame's website to figure out how to print a variable or determine its type and have not found documentation on that. Do you have suggestions of where to start with that?

    Much appreciated,

  • Hi Nelly,

    The reason you don't find anything on the Opensesame documentation is that it is not an Opensesame question. The code you write in inline_scripts is basically plain Python code, so in order to find specific commands regarding syntax, etc., you have to browse the Python documentation.

    Well anyway, what you need is the print and the type command. Use them like that:

    a = 1 b = u'2' print type(a), a # prints the type of a and a print type(b), b # prints the type of b and b print a + b # This will throw a TypeError print a + int(b) # this will give 3

    Hope this clears things up.


Sign In or Register to comment.