Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!van-bc! From: lphillips@lpami.wimsey.bc.ca (Larry Phillips) Newsgroups: comp.sys.amiga Subject: Re: Random sound on Startup... Message-ID: <1841@lpami.wimsey.bc.ca> Date: 3 Aug 90 14:35:53 GMT Lines: 37 Return-Path: To: van-bc!rnews In <4933@eklektik.UUCP>, eric@eklektik.UUCP (/dev/tty000) writes: > >I've done a similar thing in my startup using ARexx and Joe Hitchens' nifty >Tapestry program. This randomly chooses a picture out of my s:pix directory >and installs it as a backdrop picture. Basically, all it does is do a >directory of s:pix, counts the files, choose one randomly, then call tapestry. >The complete script is here. (Most of it is a custom random function, >rxandom(), since ARexx's builtin random function kept giving me the same >pictures...) The seed for the Arexx random number generator is initialized to a particular value when it is loaded, and started from the same seed, random() will always produce the same initial value, and from that, seed the random number generator with the same seed value for its next call, giving you the same sequence. What you want to do is to generate the initial seed with the randu() function, and base it on something that has a fairly good chance of being random enough within your application to suit the purpose. Here's your program, modified. ------------- Cut Here -------------- /* Tapestry.rexx -- Randomly choose a picture file for tapestry to display */ files = showdir("s:pix") call randu(1000*time('S')) address command "run tapestry s:pix/"||word(files,random(1,words(files))) >exit >------------- Cut Here -------------- -larry -- Sex is better than logic, but I can't prove it. +-----------------------------------------------------------------------+ | // Larry Phillips | | \X/ lphillips@lpami.wimsey.bc.ca -or- uunet!van-bc!lpami!lphillips | | COMPUSERVE: 76703,4322 -or- 76703.4322@compuserve.com | +-----------------------------------------------------------------------+