I usually use getOne to check if items exist in a linear 
list, so a one-liner would be:

on addItem theList, theItem
if not theList.getOne(theItem) then 
theList.add(theItem)

jj

On Wed, 13 Dec 2000 20:59:03 +0800 John Erazo 
<[EMAIL PROTECTED]> wrote:
>From: "Thomas Yeh" <[EMAIL PROTECTED]>
>
>> So maybe instead of stepping through the list 
ourseleves, we can just let
>> the underlying C or Assembly code does it for us, 
as in following handler.
>>
>> on addItem theList, theItem
>>   if not ilk(theList, #linearList) then exit
>>   itemPos = theList.getPos(theItem)
>>   if itemPos then return itemPos
>>   theList.add(theItem)
>>   return theList.getPos(theItem)
>> end
>
>Thank you,  Thomas.
>
>Yes. You are right when you said that it is case 
sensitive
>as in the following example...
>
>-- Welcome to Director --
>put gList
>-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn"]
>
>put getPos(gList, "Earth")
>-- 1
>
>put getPos(gList, "EARTH")
>-- 0
>
>put getPos(gList, "earth")
>-- 0
>
>-- Your script at work.
>addItem(gList, "earth")
>
>put gList
>-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn", 
"earth"]
>
>addItem(gList, "EARTH")
>
>put gList
>-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn", 
"earth", "EARTH"]
>
>
>Maybe going through each item on the list is till the 
safest one.
>
>Thanks again for your help.
>
>
>John Erazo
>
>
>
>[To remove yourself from this list, or to change to 
digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post 
messages to the list,
>email [EMAIL PROTECTED]  (Problems, email 
[EMAIL PROTECTED])
>Lingo-L is for learning and helping with 
programming Lingo.  Thanks!]
>
>

*********************************************
Want free email? Sign up at http://www.freeze.com !

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to