[comp.binaries.ibm.pc.d] An oddity with looz and turbo pascal's random

bsrdp@warwick.ac.uk (Hylton Boothroyd) (06/23/89)

A couple of years ago I wrote a short turbo pascal 3 programme to generate
8-character random alpha strings.

I've just been surprised by the result of putting a copy in a .ZOO and
running it under MSDOS 3.20 on an XT clone. Using
	   looz xx zoohive rndname
I get the same string each time:
	   kkiioriv .

Giving the programme a different name and putting it in a different .ZOO
yields the same string!

The command works OK at DOS command level - or more strictly at the DOS/CED
command level that one of Rahul's remarks nudged me towards.

The odd behaviour of this one programme is not important to me in itself. I
just happened to use it as an example in testing out a set of command
structures.  What disturbs me is that I can't see why it might happen, and I
therefore can't guess the class of circumstances in which there might be
changed behaviour.

Any comments?

-----------------------
Hylton Boothroyd        Janet: h.boothroyd@uk.ac.warwick.cu
Warwick Business School Darpa: h.boothroyd%cu.warwick.ac.uk@relay-nsfnet.ac.uk
University of Warwick   Uucp:  h.boothroyd%sol@warwick.uucp
COVENTRY                Earn/Bitnet: h.boothroyd%uk.ac.warwick.cu@UKACRL
England  CV4 7AL        Phone: +44 203 523523  Extension 2428
-----------------------

leonard@bucket.UUCP (Leonard Erickson) (06/29/89)

In article <3008@sol.warwick.ac.uk> bsrdp@warwick.ac.uk (Hylton Boothroyd) writes:
<A couple of years ago I wrote a short turbo pascal 3 programme to generate
<8-character random alpha strings.
<
<I've just been surprised by the result of putting a copy in a .ZOO and
<running it under MSDOS 3.20 on an XT clone. Using
<	   looz xx zoohive rndname
<I get the same string each time:
<	   kkiioriv .
<
<Giving the programme a different name and putting it in a different .ZOO
<yields the same string!
<
<The command works OK at DOS command level - or more strictly at the DOS/CED
<command level that one of Rahul's remarks nudged me towards.
<
<The odd behaviour of this one programme is not important to me in itself. I
<just happened to use it as an example in testing out a set of command
<structures.  What disturbs me is that I can't see why it might happen, and I
<therefore can't guess the class of circumstances in which there might be
<changed behaviour.

As I recall the random routines in TP3 use some chunk of memory for a seed. 
When you run it from inside the Zoo file, this chunk of the DOS environment
will *always* be the same. Try putting the program in your autoexec and
you'll get the same kind of result.

Remember, programs *can't* generate truly random numbers, only psuedo-
random ones. If the machine state is the same, the output will be the same.

-- 
Leonard Erickson		...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I'm all in favor of keeping dangerous weapons out of the hands of fools.
Let's start with typewriters." -- Solomon Short