Clearitems();


Author
Message
desiree80
desiree80
Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)
Group: Forum Members
Posts: 14, Visits: 110
Hello,
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/74lk1oxtbh74qgtb6f1cecudlaiak4sy

Thank you!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
desiree80 - Wednesday, December 19, 2018
Hello,
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/74lk1oxtbh74qgtb6f1cecudlaiak4sy

Thank 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.

Attachments
Definitions_Measurement_2.iqx (418 views, 72.00 KB)
desiree80
desiree80
Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)Esteemed Member (1.5K reputation)
Group: Forum Members
Posts: 14, Visits: 110
As always you are awesome! Thanks again!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search