>I'm trying to build a script that it will NOT add an item
>to a global list if that item already exist.
>
>on addItem inItem
>   global gList
>   set totalCount = gList.count
>   repeat with i = 1 to totalCount
>     put inItem = gList[i]

John, this line is your problem. You're setting inItem to the value of 
gList[i]. Try this:

global gList

on addItem inItem
   totalCount = gList.count
   repeat with i = 1 to totalCount
     if gList[i] = inItem then
       alert "Item already exists."
       return VOID
     else
       gList.add(inItem)
       -- take out the exit repeat
     end if
   end repeat
end

HTH.

Cordially,
Kerry Thompson
Learning Network


[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