Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
3D Sprite
Windows NT and Audio
MD5
QuickDraw 3D
Loungin.net
Lingo Paradise Smartgroups
DirectInteraction Xtra
Get Member Modified Time and Date
==> FlashFere2.2 Available now !!
Set Sound Property of a Flash member
MediaMacros Xtras Mall
 

 

 

Behavior Useful list functions

Added on 7/27/1999

 

Compatibilities:
D7 D8 Mac PC Script Shockwave

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

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail