Howdy, Stranger!

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

Supported by

how to make variable's name dynamic in exp.pool[] box - inline script

edited May 7 in OpenSesame

Hi there,

I was searching answer for whole day, but can't find one, almost give in.

Basically, my question is:

In inline script (attached), I want make the var.xxx become dynamic (yes, works) and work as variable in exp.pool[] to refer different column names in the loop that list all the image names (this doesn't work :'( ).

for example:


i = random.randint(12,30)

var.xxx = u'var.bmi_F_' + str(i)

path = exp.pool[var.xxx]

face_canvas.image(path, x=0)

face_canvas.show()

while True:

r, timestamp = my_keyboard.get_key(keylist=[u'up', u'down', u'space'])

if r == u'up':

if i < 30:

i=i+1

var.xxx = u'var.bmi_F_' + str(i)

path = exp.pool[var.xxx]

face_canvas.image(path, x=0)

face_canvas.show()

elif r == u'down':

if i>12:

i=i-1

var.xxx = u'var.bmi_F_' + str(i)

path = exp.pool[var.xxx]

face_canvas.image(path, x=0)

face_canvas.show()

elif r == u"space":

break

log.write_vars() 



Thank you in advance! If there is any suggestion!

Chengyang

Comments

  • Hi Chengyang,

    Is there an error message? What exactly is the problem? Also, I am not sure what you mean with:

    work as variable in exp.pool[] to refer different column names in the loop

    Eduard

Sign In or Register to comment.