Contents Articles Behaviors Books Director News Director Web Sites FAQ Games Mailing Lists News Groups Project Examples Reviews Software Tools Useful Web Sites Utilities Xtras

Don't miss these
 Help Studio 2000 OnStage DVD for Director Creating a Marquee Tool MultimediaHelp Replace returns with PC line breaks Shiver With Sound Field Slinky Effector Set 1 Behavior Support Install Shield Pro Setup Anim

# Useful list functions

 Compatibilities: Rating:

Author: LukeWigley

Various functions for manipulating lists, including randomisingLists, sorting Property Lists by value

 -- Functions for manipulating lists -- Last updated 7/99 on randomiseList aList   -- accepts either property or linear lists   -- and returns a randomised duplicate version of that list   listtype =  ilk (aList)   if listtype = #list then     tList = duplicate (aList)     rList = []     mx = count (tList)     repeat while mx > 0       ps = random(mx)       va = getAt (tList, ps)       append rList, va       deleteAt tList, ps       mx = count (tList)     end repeat   else if listtype = #propList then     tList = duplicate (aList)     rList = [:]     mx = count (tList)     repeat while mx > 0       ps = random(mx)       pr = getPropAt (tList, ps)       va = getAt (tList, ps)       addProp rList, pr, va       deleteAt tList, ps       mx = count (tList)     end repeat   end if   return rList end on removeDuplicates aLinearList   -- searches through a linear list   -- returns the list without any duplicates   if ilk (aLinearList) = #list then     rList = []     mx = count (aLinearList)     repeat with i = 1 to mx       v = aLinearList[i]       if getOne(rList, v) = 0 then append rList, v     end repeat     return rList   else return aLinearList end on sortByValue propListToSort   -- sorts a property list firstly by value, then by property   pList = duplicate (propListToSort)   sort pList   mx = count (pList)   rList = [:]   vList = []   repeat with valPos = 1 to mx     v = pList[valPos]     if getOne (vList, v) = 0 then append vList, v   end repeat   sort vList   mx2 = count (vList)   repeat with sortedValPos = mx2 down to 1     thisV = vList[sortedValPos]     repeat with valPos = 1 to mx       v = pList[valPos]       if v =  thisV then addProp rList, getPropAt (pList, valPos), v     end repeat   end repeat   return rList end on listContains aList, aStr   -- searchs through a linear list looking for entries that   -- contain the specified str. returns 0 if found   set mx = count (aList)   repeat with j = 1 to mx     if aList[j] contains aStr then return 0   end repeat   return -1 end on filterList sList, filterStr   -- searchs through a linear list looking for entries that   -- contain the filterStr   rList = []   mx = count (sList)   repeat with j = 1 to mx     fName = sList[j]     if fName contains filterStr then append rList, fName   end repeat   return rList end

 Contact MMI 36 South Court Sq Suite 300 Newnan, GA 30263 USA Send e-mail