Howdy, Stranger!

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

Supported by

[solved] using a variable in a loop of a higher leven

edited May 2014 in OpenSesame

Hello everybody,

I've created a loop in which a block called "trials" is located. I'd like to use the value of the count_trails variable (the counter variable of the block) in an inline script within the block itself (inline script "log_var"). Using self.get(count_trials) leads in this case to the error that variable was not defined. As you can see, there is another inline_script at the most upper level (called "Variablen"). In this inline script I use exp.set('count_trials', '0') and I even use this variable in the break condition of the loop and it works fine. So I'm wondering why I cannot use this variable within the loop and how to resolve this problem.

Thank you for your help in advance.
Cheers!

Comments

  • edited 6:49AM

    The solution is a slightly silly one: there's a syntax/logic error. You forgot to add quotes around the OpenSesame variable name. It should be as follows:

    self.get("count_trials")
    

    Alternatively, so you see precisely what went wrong in your snippet:

    my_var = "count_trials"
    self.get(my_var)
    

    Good luck!

Sign In or Register to comment.