Millisecond Forums

The value 'wordlist' is defined more than once.

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

By KO - 8/3/2015

Hi Dave,

Everything is working really well with my RSVP task - I just have a question about one thing.
I wanted Inquisit to provide me with information in the data section with regard to which wordlist a word is from. That was fairly straightforward to do, I just defined the wordlist for a second time in the values section, as / wordlist = "", and also in a few other places. This seems to work really well, but I do get the message then that "The value 'wordlist' is defined more than once." Obviously this is true. That is exactly what I did do so it would provide me with the additional information that I needed. My question is though, is this potentially problematic? As in, can I expect something to stuff up / not work at some point because of making this change?

From the answer that you provide previously to someone on a somewhat similar topic:    http://www.millisecond.com/forums/Topic15587.aspx
I would think that it isn't an issue, and the fact that it is commented on by the program is just a throwback from version 3 of Inquisit, however, I wanted to check in with you about that before I start using with participants the version of the RSVP task which includes these changes.

Many thanks
By Dave - 8/3/2015

Whether that's a problem in a practical sense in this particular case, I cannot tell you without the code. However, in general, you should *not* do this. A <values> entry is a global variable. If you define the same global variable multiple times in a script as in

<values somesetofvalues>
/ wordlist = ""
...
</values>

...

<values someothersetofvalues>
/ wordlist = ""
...
</values>

how is Inquisit supposed to know which one of those variables it should use when any of your elements refer to it as in

<trial sometrial>
/ ontrialbegin = [values.wordlist="..."; ...]
...
</trial>

?
That's the reason for the error message. And it does *not* provide you with any additional information. Each global variable should be defined once in the script and only once. Remove the duplicate(s): The error will go away and the script will still work.

Hope this clarifies.
By KO - 8/4/2015

Hi Dave,

Thank you for your post. That kind of clarifies the situation, but I think perhaps you're not aware as to what I'm using the repetition of the value.wordlist for (because I didn't mention that explicitly before), which may make a difference to what you would advise.

I have in the values section now:

/ wordlist = 0
(and)
/ wordlist = ""

So, the first of these and how it is defined further on in the coding is performing the task of actually making sure that the 4 different types of word lists are run in the program - as in this part of the script:
/ ontrialbegin = [if (values.wordlist==1) values.mystimulus = list.wordlist1items.nextvalue; ]
/ ontrialbegin = [if (values.wordlist==2) values.mystimulus = list.wordlist2items.nextvalue; ]
/ ontrialbegin = [if (values.wordlist==3) values.mystimulus = list.wordlist3items.nextvalue; ]
/ ontrialbegin = [if (values.wordlist==4) values.mystimulus = list.wordlist4items.nextvalue; ]

And then the other wordlist with "" is in order to make sure that which word belongs to which wordlist is recorded in the data section. It seems to be performing both functions at the moment without any issues, but if you think that any issues might come of doing things this way, then I guess I need your help in finding another way of getting which wordlist is being used for a given word into the data section. What are your thoughts on this?

Thanks again for your previous post and looking forward to hearing your thoughts/ideas on this.



By KO - 8/4/2015

Hi again Dave,

I was thinking again about what you said and decided to try to figure out a way around the problem of repeating the use of the wordlist and I appear to have found it. What I did was created another variable to put in the value section. So now, rather than having two lots of wordlist in the values section I have:

/ wordlist = 0
and then
/ wordtypes = ""

Then further along I then included an extra expression:

/ ontrialbegin = [values.wordlist = list.wordlist.nextvalue; values.wordtypes = list.wordlist.nextvalue; values.t1position = list.t1positionlist.nextvalue;
values.t2lag = list.t2laglist.nextvalue;]

And wherever I'd put in the additional mention of wordlists previously, as in for example the data section, I just changed it to wordtypes. It appears to work, and now I'm not getting any kind of error message now. So I think this is probably the best way of doing things then, given that I shouldn't be doing things the other way.

I'd still like to hear your thoughts if you have any particular ideas/feedback relating to the way I've set things up, but it does appear to be sorted out now.

Thanks again!



By Dave - 8/4/2015

Yes, using two distinct variables for two distinct things is the proper way to do it, in my opinion. Nevertheless, my initial point still stands:

(1) A computer, and by extension any programming language, requires *unambiguous* instructions. Defining multiple global variables with the same name does not meet that condition for the reasons already explained: How is the machine supposed to know which variable you mean in any given situation? It can't.

(2) Removing the duplicate definitions would not have made a difference. To see why, think about *when* values.wordlist gets used for what. It is of course possible to use the variable for different things at different times. It is still the same, single variable, though. Example:

<values>
/ myvalue = 0
</values>

<block myblock>
/ trials = [1-4=sequence(digit, letter)]
</block>

<trial digit>
/ ontrialbegin = [values.myvalue=list.digitlist.nextvalue]
/ stimulusframes = [1=mytext]
/ trialduration = 1000
</trial>

<trial letter>
/ ontrialbegin = [if (values.myvalue==1) values.myvalue=list.alist.nextvalue]
/ ontrialbegin = [if (values.myvalue==2) values.myvalue=list.blist.nextvalue]
/ stimulusframes = [1=mytext]
/ trialduration = 1000
</trial>

<list digitlist>
/ items = (1,2,1,2)
</list>

<list alist>
/ items = ("A1", "A2")
</list>

<list blist>
/ items = ("B1", "B2")
</list>

<text mytext>
/ items = ("<%values.myvalue%>")
</text>

<data>
/ columns = [subject trialnum trialcode values.myvalue]
/separatefiles = true
</data>


By KO - 8/5/2015

Hi Dave,

I get it now. :-) I was over-complicating the coding I was doing.  That's definitely good to know. :-)   So if I take out the additional stuff I'd thought that I needed to put in and only include: values.wordlist
in the data section then the script still does exactly what I want it to, and that's because the same variable can serve the two functions within the task without needing to be defined more than once in the values section as I'd originally thought - and in fact doing so was what was causing the problem.

Thanks for the example you included in your previous post as well. That really helped with figuring things out.

Thanks so much for all of your help again! It's good to know that the simpler approach is fine to use in cases like this.