Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!rutgers!att!alberta!calgary!!kish From: kish@.ucalgary.ca (Bradley John Kish) Newsgroups: comp.sys.mac.programmer Subject: Re: Random help, please Keywords: DA,random Message-ID: <649@cs-spool.calgary.UUCP> Date: 3 Feb 89 16:08:48 GMT References: <69823DN5@PSUVM> Sender: news@calgary.UUCP Reply-To: kish@enelf.UUCP (Bradley John Kish) Organization: U. of Calgary, Calgary, Alberta, Canada Lines: 29 In article <69823DN5@PSUVM> DN5@PSUVM.BITNET writes: >Hi netlanders: > > I am working on a DA which needs some random numbers. My problem is that >I always get the same sequence. I have tried setting randSeed, but this >doesn't seem to do anything (actually I set it before I call Random, then >save this value, then reset the original value, so that it won't mess up >an application). However, anything I do (including attempting a FOR loop >repeating for a somewhat random time (GetTimeDate + CountTicks), seems to >do nothing: I still get the same sequence. The problem has to do with the way the Mac handles DA's and the Random number seed. The random number seed is stored as a GLOBAL and DA's aren't allowed to touch with them. I can't remember what what nasty things happen if you do mess with them, though. To get around this problem you have to write your own random number generator. Any good book on computer algorithms will have one. To start off randomly, set your seed to the system clock. Hope this was of some help. Good Luck! Brad Kish. *** What's all this disclaimer jazz anyway? kish@enel.UCalgary.CA