Millisecond Forums

listing variables as list items

https://forums.millisecond.com/Topic20434.aspx

By jamieward - 1/4/2017

I am wanting to use variables as list items, along the lines of the following code but in which the variable will be dynamically defined by the user.  Whenever I try to run the code it tells me that it wants double quotes for the items.  That is, it doesn't seem to realise that these are text variables.

Any suggestions?
Jamie

<values>
/self_shape = "a.bmp"
/friend_shape = "b.bmp"
/stranger_shape = "c.bmp"
/currentstim=0
</values>

<item  shape>
/1 = values.self_shape
/2 = values.friend_shape
/3 = values.stranger_shape
/4 = values.self_shape
/5 = values.friend_shape
/6 = values.stranger_shape
/7 = values.friend_shape
/8 = values.self_shape
/9 = values.self_shape
/10 = values.stranger_shape
/11 = values.stranger_shape
/12 = values.friend_shape
</item>

<picture display_shape>
/items = shape
/select = values.currentstim
/position = (50%, 25%)
</picture>
By Dave - 1/4/2017

jamieward - Wednesday, January 4, 2017
I am wanting to use variables as list items, along the lines of the following code but in which the variable will be dynamically defined by the user.  Whenever I try to run the code it tells me that it wants double quotes for the items.  That is, it doesn't seem to realise that these are text variables.

Any suggestions?
Jamie

<values>
/self_shape = "a.bmp"
/friend_shape = "b.bmp"
/stranger_shape = "c.bmp"
/currentstim=0
</values>

<item  shape>
/1 = values.self_shape
/2 = values.friend_shape
/3 = values.stranger_shape
/4 = values.self_shape
/5 = values.friend_shape
/6 = values.stranger_shape
/7 = values.friend_shape
/8 = values.self_shape
/9 = values.self_shape
/10 = values.stranger_shape
/11 = values.stranger_shape
/12 = values.friend_shape
</item>

<picture display_shape>
/items = shape
/select = values.currentstim
/position = (50%, 25%)
</picture>

Valid syntax would look like the below. You should also define a <picture> element in the script that has the image files defined as items (even if you don't actually use that <picture> element anywhere else in the script). Otherwise you could run into problems under some circumstances, for example when deploying the script online, because Inquisit would not necessarily know to download the actual files before starting to execute the script.

<values>
/self_shape = "a.bmp"
/friend_shape = "b.bmp"
/stranger_shape = "c.bmp"
/currentstim=0
</values>

<item shape>
/1 = "<%values.self_shape%>"
/2 = "<%values.friend_shape%>"
/3 = "<%values.stranger_shape%>"
/4 = "<%values.self_shape%>"
/5 = "<%values.friend_shape%>"
/6 = "<%values.stranger_shape%>"
/7 = "<%values.friend_shape%>"
/8 = "<%values.self_shape%>"
/9 = "<%values.self_shape%>"
/10 = "<%values.stranger_shape%>"
/11 = "<%values.stranger_shape%>"
/12 = "<%values.friend_shape%>"
</item>

<picture display_shape>
/items = shape
/select = values.currentstim
/position = (50%, 25%)
</picture>

<picture dummypic>
/ items = ("a.bmp", "b.bmp", "c.bmp")
</picture>

<trial mytrial>
/ ontrialbegin = [
    values.currentstim += 1
]
/ stimulusframes = [1=display_shape]
/ validresponse = (57)
</trial>

<block myblock>
/ trials = [1-12 = mytrial]
</block>