home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 6 / MacAddict_006_1997_02.iso / media / Main.Dxr / Internal_19_randomListMaker.ls < prev    next >
Encoding:
Text File  |  1996-11-25  |  443 b   |  25 lines

  1. property randomList, listSize, nextItem
  2.  
  3. on new me, howMany
  4.   set listSize to howMany
  5.   generateList()
  6.   return me
  7. end
  8.  
  9. on getNextRandom
  10.   if nextItem > listSize then
  11.     generateList()
  12.   end if
  13.   set thisNumber to getAt(randomList, nextItem)
  14.   set nextItem to nextItem + 1
  15.   return thisNumber
  16. end
  17.  
  18. on generateList
  19.   set randomList to []
  20.   repeat with x = 1 to listSize
  21.     addAt(randomList, random(x), x)
  22.   end repeat
  23.   set nextItem to 1
  24. end
  25.