home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
modula2
/
library
/
queuem2
/
makeseed.mod
< prev
next >
Wrap
Text File
|
1989-08-02
|
2KB
|
63 lines
(* source: h:\modula\code\random\MakeSeed.MOD v1.0a revised: 88.07.01
author: G.Greene, AGCS D/429 (NS/TS), 312/681-7783 created: 88.07.01
function:
This file contains the implementation code for a module which mangles the
system date and time into a sort-of random starting value to use a the
parameter to SetSeedValue in module UnifRNG.
history:
88.07.01 1.0a initial release
*)
IMPLEMENTATION MODULE MakeSeed;
FROM SYSTEM IMPORT (*TYPE*) Registers;
FROM Lib IMPORT (*PROC*) Dos;
(* Return as the function value a value suitable for use as the parameter to
procedure SetSeedValue in module UnifRNG. This value will be different
every time it is called, so that one can get different random sequences
from any of the random number generators (since all of them ultimately
use uniform variates from UnifRNG).
Implementation note: since this procedure is likely to be called only
once in any application, it is not designed for time efficiency. If the
compiler has options for speed vs. code size optimization, the code size
optimization should be chosen.
*)
PROCEDURE MakeSeedValue ( ): LONGCARD;
TYPE
LongCardMasks =
RECORD
CASE which: BOOLEAN OF
TRUE:
longvalue: LONGCARD;
|
FALSE:
lowvalue,
highvalue: CARDINAL;
END; (* CASE *)
END; (* LongInt *)
VAR
Regs: Registers;
LongCard: LongCardMasks;
BEGIN
Regs .AH := 2CH;
Dos ( Regs );
LongCard .highvalue := Regs .DX;
LongCard .lowvalue := Regs .CX;
RETURN LongCard .longvalue;
END MakeSeedValue;
END MakeSeed.