[comp.os.vms] IMPROVEMENT TO MY COOKIE PROGRAM

graham@DRCVAX.ARPA (07/28/87)

Greetings cookie eaters:

Many of you have received my fortune cookie program.  (Many more probably 
will after they see this posting...it's O.K., though)  The random number 
generator in that program leaves something to be desired.  After a couple 
of suggestions, I have rewritten the portion of code that generates the 
random numbers.  It is short and works much better.

Here's how to modify the cookie.for program:

1. Delete all of the subroutine.

2. Make the data declaration lines at the top look like this:

	INTEGER*4 NUM,VALUE,VAL,COUNT,MAX,SEED
	REAL*4 SYSTIME,MTH$RANDOM,RNUM
	CHARACTER*80 LINE
	CHARACTER*1 NULL

3. delete thr line
	CALL RANDOM(NUM,MAX)

4. In it's place, enter the lines
	SYSTIME = SECNDS(0.0)
	SEED = ANINT(SYSTIME)
	NUM = 0
3	RNUM = MTH$RANDOM(SEED)
	NUM = ABS(RNUM) * 10000
	IF (NUM .EQ. 0 .OR. NUM .GT. MAX) GOTO 3

Recompile, link and you're set.


I hope this is better.  Good luck.

Dan Graham
GRAHAM@DRCVAX.ARPA
------