Hi everyone.
I think have I found a better approach to what was
I was trying to achieve - a case-insensitive search
through a linear list of text strings. getOne() and
getPos() will not work in my situation.
In the Message window.
-- Welcome to Director --
put gList
-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn"]
put gList.getOne("Earth")
-- 1
put gList.getOne("earth")
-- 0
put gList.getPos("Jupiter")
-- 2
put gList.getPos("JUPITER")
-- 0
Since I was dealing with text in my list,
I decided to make the linear list as a string as in
string(theLinearList). With my list as a string, I can
search for an item using the operator contains.
The nice thing about comparing string values
is that they are not case sensitive.
In the Message window.
-- Welcome to Director --
thisItem = "Mercury"
put thisItem = "mercury"
-- 1
put thisItem = "MERCURY"
-- 1
put thisItem = "MeRcUrY"
-- 1
So, I was able to come up with this.
-- Movie script starts here.
on addItem inList, inItem
if not ilk(inList, #linearList) then return void
if string(inList) contains inItem then exit
inList.append(inItem)
end
-- Movie scripts ends here.
In the Message window.
-- Welcome to Director --
showGlobals
-- Global Variables --
version = "8.0"
gList = ["Earth", "Jupiter", "Mars", "Venus", "Saturn"]
addItem(gList, "earth")
put gList
-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn"]
addItem(gList, "EARTH")
put gList
-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn"]
addItem(gList, "Mercury")
put gList
-- ["Earth", "Jupiter", "Mars", "Venus", "Saturn", "Mercury"]
I also find this approach a bit faster rather than using the
convetional list (that is if I'm using getPos() or getOne()).
Hope I'm making sense to what I have came up with.
Have a nice day everyone. = :-)
cheers,
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!]