[texworks] SCRIPTS: TW.getItem() returning everything lower case?

Paul A Norman paul.a.norman at gmail.com
Thu Dec 9 10:48:46 CET 2010


Oh well, its still there some times -

var optionsList = new Array("Abcd","abcd","ABCD","ABCD","Efgh", "EFGH");

didn't completely solve it.

I'll focus on Qt forums - unless someone comes up with another idea here.

Paul

On 9 December 2010 21:50, Paul A Norman <paul.a.norman at gmail.com> wrote:
> I've posted on a Qt forum, so hopefully that will get us somewhere.
>
> This as I have been saying did not work (though prior to rev 649 it does):
>
>  sizeCommand =  TW.getItem( null, "Text/Font Size?", "Choose Text
> Font/Size: ",
>  ["Abcd","abcd","ABCD","ABCD","Efgh", "EFGH"] , 1 , true ) ;
>
> And this did not work:
>
> var optionsList = ["Abcd","abcd","ABCD","ABCD","Efgh", "EFGH"];
>
>  sizeCommand =  TW.getItem( null, "Text/Font Size?", "Choose Text
> Font/Size: ",
>  optionsList , 1 , true ) ;
>
> This bypasses the problem and **works**.
> Explicit old fashioned array declaration constructor.
>
> var optionsList = new Array("Abcd","abcd","ABCD","ABCD","Efgh", "EFGH");
>
> sizeCommand =  TW.getItem( null, "Text/Font Size?", "Choose Text
> Font/Size: ", optionsList , 1 , true ) ;
>
> As far as I know all the above are valid ECMA.
>
> Paul
>
> On 9 December 2010 20:04, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> On 2010-12-09 06:01, Paul A Norman wrote:
>>> Ok more accurate osilation of problem,
>>>
>>> There appears to be something about the way that the lists are built
>>> internally by recent versions of Qt perhaps.
>>>
>>> The behaviour is not fickle but seems to be predictable. It appears
>>> that it actually has nothing to do with uppercase / lowercase as such.
>>>
>>> If items in a list are case-insensitively the same, then the first
>>> occurrence of a common sequence of letters seems to typecast the rest
>>> - they are all recognised as the same.
>>>
>>> ["ABCD", "abcd","Abcd","ABCD", "Efgh"]
>>>
>>> First three elements are always coming out as ABCD
>>>
>>>
>>> [ "abcd","ABCD","Abcd","ABCD", "Efgh"]
>>>
>>> First three elements are always coming out as abcd
>>>
>>>
>>> ["Abcd", "abcd","ABCD","ABCD", "Efgh"]
>>>
>>> First three elements are always coming out as Abcd
>>>
>>>
>>> Efgh is always exactly as wanted, as there is no earlier occurance.
>>>
>>> Use this however
>>>
>>> ["Abcd","abcd","ABCD","ABCD","Efgh", "EFGH"]
>>>
>>> And try for EFGH and you'll get Efgh.
>>
>> Hm, this is curious, and definitely sounds like a Qt bug (possibly in
>> the QtScript implementation?). As a workaround, did you try to build the
>> array differently? E.g., creating an empty array and adding elements one
>> by one (with v[0]=..., v[1]=..., etc.)? Maybe it has something to do
>> with the handling of all elements at once in the constructor...
>>
>> HTH
>> Stefan
>>
>



More information about the texworks mailing list