+xHello,
I'm working on a code that uses an empty sound element so that I can assign the wav files later in the trial. I found that the sound object is storing all of the wav files I assign to it instead of clearing all the items like I specified. Open the debugger and type in sound.aAdudio. Do you see how it keeps adding stimuli to aAudio and does not clear them? When I click the speaker picture it loops through all the sounds instead of only the one I want. Am I using clearitems incorrectly?
Here is a link with the files, the main file is called Definitions_Measurement_2.iqx:
https://usf.box.com/s/74lk1oxtbh74qgtb6f1cecudlaiak4syThank you!
I don't think you're using clear() wrongly, but it's actually unnecessary to permanently clear all items to get what you want. It's more straightforward and better performance-wise to simply always replace the first item in the respective <text> and <sound> elements, i.e.
<expressions>
...
/settrialstimuli=
if(values.order==1){
text.option1.
items.1=getItem(item.distractor_1_txt,values.index);
text.option2.items.1=getItem(item.distractor_2_txt, values.index);
text.option3.items.1=getItem(item.distractor_3_txt,values.index);
text.option4.items.1=getItem(item.word_txt,values.index);
sound.aaudio.
items.1=getItem(item.distractor_1_sound,values.index);
sound.baudio.items.1=getItem(item.distractor_2_sound,values.index);
sound.caudio.items.1=getItem(item.distractor_3_sound,values.index);
sound.daudio.items.1=getItem(item.word_sound,values.index);
values.correctoption=text.option4.currentitem;
};
if(values.order==2){
text.option1.
items.1=getItem(item.distractor_2_txt,values.index);
text.option2.items.1=getItem(item.distractor_3_txt, values.index);
text.option3.items.1=getItem(item.word_txt,values.index);
text.option4.items.1=getItem(item.distractor_1_txt,values.index);
sound.aaudio.
items.1=getItem(item.distractor_2_sound,values.index);
sound.baudio.items.1=getItem(item.distractor_3_sound,values.index);
sound.caudio.items.1=getItem(item.word_sound,values.index);
sound.daudio.items.1=getItem(item.distractor_1_sound,values.index);
values.correctoption=text.option3.currentitem;
};
if(values.order==3){
text.option1.
items.1=getItem(item.distractor_3_txt,values.index);
text.option2.items.1=getItem(item.word_txt, values.index);
text.option3.items.1=getItem(item.distractor_1_txt,values.index);
text.option4.items.1=getItem(item.distractor_2_txt,values.index);
sound.aaudio.
items.1=getItem(item.distractor_3_sound,values.index);
sound.baudio.items.1=getItem(item.word_sound,values.index);
sound.caudio.items.1=getItem(item.distractor_1_sound,values.index);
sound.daudio.items.1=getItem(item.distractor_2_sound,values.index);
values.correctoption=text.option2.currentitem;
};
if(values.order==4){
text.option1.
items.1=getItem(item.word_txt,values.index);
text.option2.items.1=getItem(item.distractor_1_txt, values.index);
text.option3.items.1=getItem(item.distractor_2_txt,values.index);
text.option4.items.1=getItem(item.distractor_3_txt,values.index);
sound.aaudio
.items.1=getItem(item.word_sound,values.index);
sound.baudio.items.1=getItem(item.distractor_1_sound,values.index);
sound.caudio.items.1=getItem(item.distractor_2_sound,values.index);
sound.daudio.items.1=getItem(item.distractor_3_sound,values.index);
values.correctoption=text.option1.currentitem;
};
values.option1value=text.option1.currentitem;
values.option2value=text.option2.currentitem;
values.option3value=text.option3.currentitem;
values.option4value=text.option4.currentitem;
...
</expressions>
with
<text option1>
/ items = ("blank")
/ position = (50%,40%)
/txbgcolor = transparent
/ fontstyle = ("Arial", 15pt, false)
/erase = false
/select = 1
</text>
<text option2>
/ items = ("blank")
/ position = (50%,50%)
/txbgcolor = transparent
/ fontstyle = ("Arial", 15pt, false)
/erase = false
/select = 1
</text>
<text option3>
/ items = ("blank")
/ position = (50%,60%)
/txbgcolor = transparent
/ fontstyle = ("Arial", 15pt, false)
/erase = false
/select = 1
</text>
<text option4>
/ items = ("blank")
/ position = (50%,70%)
/txbgcolor = transparent
/ fontstyle = ("Arial", 15pt, false)
/erase = false
/select = 1
</text>
and
<sound aAudio>
/ items = ("blank.wav")
/ select = 1
</sound>
<sound bAudio>
/ items = ("blank.wav")
/ select = 1
</sound>
<sound cAudio>
/ items = ("blank.wav")
/ select = 1
</sound>
<sound daudio>
/ items = ("blank.wav")
/ select = 1
</sound>
A revision of your script implementing the above approach is attached. Hope this helps.