Millisecond Forums

Error manipulating item-Elemts

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

By luffy - 11/14/2013

I'm trying to change the contents of an item-element but always get the errormessage:
"Unable to initialize <picture animal> item number 1. Verify the item exists and is correctly defined." 


Example:


<item Animal> / 1 = "dog.png" </item>


<picture animal> / items = Animal </picture>


 


<trial dog>


/ stimulustimes = [0=animal] / timeout = 1000


</trial>


 


<trial cat>


/ ontrialbegin = [item.Animal.setitem("cat.png",1)]


/ stimulustimes = [0=animal] / timeout = 1000


</trial>


 


<trial cat2>


/ ontrialbegin = [setitem(item.Animal,"cat.png",1)]


/ stimulustimes = [0=animal] / timeout = 1000


</trial>


Trial "dog" is working. For the other two i get the error. The help-page for the item-element lists "setitem" as a function, but not the other way round. Does this mean it is not possible to do this? Manipulating the picture-element would be a bad option for me because i have several of those referencing the same set of items.


By Dave - 11/14/2013

If you wanted to do this, you would first have to make Inquisit aware that a file called "cat.png" actually exists and make it available to it as an object:


<block mmyblock>
/ trials = [1=sequence(dog, cat)]
</block>

<item Animal>
/ 1 = "dog.png"
</item>

<picture animal>
/ items = Animal
</picture>

<trial dog>
/ stimulustimes = [0=animal]
/ timeout = 1000
</trial>

<trial cat>
/ ontrialbegin = [setitem(item.Animal,"cat.png",1)]
/ stimulustimes = [0=animal]
/ timeout = 1000
</trial>

<picture dummy>
/ items = myitems
</picture>

<item myitems>
/ 1 = "cat.png"
</item>


However, this approach is both inefficient as well as prone to runtime errors. The proper way to do this is:


<block mmyblock>
/ trials = [1-2=sequence(dog, cat)]
</block>

<values>
/ itemnumber = 1
</values>

<item Animal>
/ 1 = "dog.png"
/ 2 = "cat.png"
</item>

<picture animal>
/ items = Animal
/ select = values.itemnumber
</picture>

<trial dog>
/ ontrialbegin = [values.itemnumber=1]
/ stimulustimes = [0=animal]
/ timeout = 1000
</trial>

<trial cat>
/ ontrialbegin = [values.itemnumber=2]
/ stimulustimes = [0=animal]
/ timeout = 1000
</trial>

By luffy - 11/14/2013

Thank you!


Will try this out after the weekend.