Hello everyone,
I'm trying to build a script that it will NOT add an item
to a global list if that item already exist. In a movie script...
on startMovie
global gList
set gList = ["Earth","Jupiter","Mars","Venus","Saturn"]
end
on addItem inItem
global gList
set totalCount = gList.count
repeat with i = 1 to totalCount
put inItem = gList[i]
if inItem = gList[i] then
alert "Item already exist."
return VOID
else
gList.add(inItem)
exit repeat
end if
end repeat
end
When I run the above script in the Message window,
this is what I got...
-- Welcome to Director --
addItem("earth")
-- 1
addItem("Jupiter")
-- 0
put gList
-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn", "Jupiter"]
addItem("Jupiter")
-- 0
put gList
-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn", "Jupiter", "Jupiter"]
addItem("Mars")
-- 0
addItem("earth")
-- 1
... it seems that it only process the first item
in gList so it keeps on adding an item which
definitely exist.
Any help is very much appreciated.
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!]