Hey all,
I needed an easier way to deal with lists so I made these functions
so far it only deals with linear lists but I am working on propertyLists
so in your movie script:
on prepareMovie
global array
array = new (script"Array Parent")
end
Then in your movie you can use it as such:
myList = [1,2,"a",6,"g"]
temp = array._shift(myList)
array._push(myList,temp)
put myList
[2,"a",6,"g",1]
Array Parent --script's name (parent script)
-------------------------------------------------
on new me
return me
end
on _shift me, tempList --variable = array._shift(list)
myValue = templist[1]
deleteAt(tempList,1)
return myValue
end
on _unshift me, tempList, myValue -- array._unshift(list,value)
addAt (tempList, 1, myValue)
end
on _push me, tempList, myValue -- array._push(list,value)
append(tempList,myValue)
return
end
on _pop me, tempList --variable = array._pop(list)
myValue = tempList[tempList.count]
deleteAt(tempList,tempList.count)
return myValue
end
on _reverse me,tempList --list = array._reverse(list)
temp = []
arrayCount = tempList.count
repeat with i = 1 to arrayCount
temp[i] = tempList[(arrayCount - (i - 1))]
updateStage
end repeat
tempList = temp
return tempList
end
on _sort me, tempList -- array._sort(list)
tempList.sort()
return
end
on _join me,tempList,seperator -- variable =
array._join(list,seperator(optional))
arrayCount = tempList.count - 1
if seperator.length = 0 then seperator = ","
newString = tempList[1] & seperator
repeat with i = 2 to arrayCount
newString = newString & tempList[i] & seperator
updateStage
end repeat
newString = newString & tempList[arrayCount + 1]
return newString
end
on _slice me,tempList, startPoint, endPoint --variable =
array._slice(list,start,end)
temp = []
endPoint = endPoint - 1
repeat with i = startPoint to endPoint
append(temp,tempList[i])
updateStage
end repeat
return temp
end
on _splice me,
tempList,startPos,numOfElements,insertA,insertB,insertC,insertD,insertE,insertF,
insertG,insertH,insertI --
array._splice(list,start,numberOfelements,anything to insert in it's place)
repeat with i = 1 to numOfElements
deleteAt(tempList,startPos)
updateStage
end repeat
-- must get better way to search function argument
temp = ["A","B","C","D","E","F","G","H","I"]
repeat with i = 1 to 9
if voidP(value("insert"&temp[i])) then
exit repeat
else
addAt (tempList, (startPos + (i - 1)), value("insert"&temp[i]))
end if
end repeat
end
Hope you find them as useful as I am.
:b)
____________________________________
Flash/Director/JavaScript
Imaginary Studio
http://www.imaginarystudio.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!]