One way that I have seen this done (and I think that I've actually used this method), is to have an array of 320 elements. The elements could be the names of the files. What you can do is randomly pick two of the elements and switch their positions using the SWAP command. Do this a few hundred times and your list should be quite un-alphabetical. Off the top of my head, I'm not sure how many swaps would do the trick. Hope this helps. -jonathan2 ********************* Jonathan Neff Macintosh Team Indiana University Bloomington IN 47408 jjneff@... ********************* >I have an alphabetic order list of file names which I need to randomize. > >If I have, say, 320 files, how do I create a random list of numbers from 1 >to 320 such that every number from 1 to 320 appears once and only once in >the randomized sequence? > >If I use RND(320) I believe some individual numbers will be generated more >than once... > >If I do something like: > >CLEAR LOCAL >LOCAL FN okToAddRandom(aRandom%, CurrCount%) > DIM okToAdd%, count% > > FOR count% = 1 TO CurrCount% > LONG IF gRandom%(count%) = aRandom% > okToAdd% = _false > count% = CurrCount% > XELSE > okToAdd% = _true > END IF > NEXT count% > >END FN = okToAdd% > >CLEAR LOCAL >LOCAL FN getRandomSequence(fileCount%) > DIM CurrTime&, mySeed%, count%, okCount% > ' fileCount% <= 320 > ' dim gRandom%(320%) done in GLOBALS file > > CurrTime& = [_time] > mySeed% = CurrTime&/(256*256) > mySeed% = ABS(mySeed%) > RANDOM mySeed% > > okCount% = 0 > WHILE count% < fileCount% + 1 > myrandom% = RND(fileCount%) > LONG IF okCount% = 0 > gRandom%(1) = myrandom% > okCount% = 1 > count% = 1 > XELSE > 'at least one myrandom% has been added to gRandom%(count%) > LONG IF FN okToAddRandom(myrandom%, count%) =_true > count% = count% + 1 > gRandom%(count%) = myrandom% > END IF > END IF > WEND > >END FN > >I can see that certain sequences for 320 numbers would take a long, long >time, some thing like 320*320 (102,400) passes to produce a fully populated, >random sequence? > >Is there a better way? > >Cheers >---------------------------------------------------------- >Michael Evans >Manager of Software Development * Photo Systems, Inc. >3301 Wood Valley Road, NW * Atlanta, GA, 30327-1515 >Voice: (404) 846-9386 >Fax: (404) 240-0878 * Cell: (404) 229-3930 >E-mail: evans@... * michael_evans@... >---------------------------------------------------------- > >-- >To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>