--RandomDefs.Mesa
-- Copywrite Xerox Corporation 1980
-- By MBrown June 22, 1979 1:45 PM
-- Last modified by LStewart September 15, 1979 9:39 PM
-- to print random floats as a test of floatio
DIRECTORY
RealDefs: FROM "RealDefs",
RandomDefs: FROM "RandomDefs",
IODefs: FROM "IODefs",
StringDefs: FROM "StringDefs",
StreamDefs: FROM "StreamDefs",
DisplayDefs: FROM "DisplayDefs";
RandomTest: PROGRAM IMPORTS RandomDefs, RealDefs, IODefs, DisplayDefs, StringDefs, StreamDefs = BEGIN
pgen: POINTER TO RandomDefs.GeneratorState;
s:STRING ← [80];
ch: CHARACTER;
runFree: BOOLEAN ← FALSE;
i: LONG INTEGER;
ks: StreamDefs.KeyboardHandle;
ks ← StreamDefs.GetDefaultKey[];
DisplayDefs.SetTypeScript[NIL];
pgen ← RandomDefs.CreateRandom[];
WHILE TRUE DO
[] ← pgen.InitRandom[pgen, 0,-1];
WHILE TRUE DO
i ← pgen.Random[pgen];
s.length ← 0;
StringDefs.AppendLongDecimal[s,i];
StringDefs.AppendString[s," "];
RealDefs.AppendFloat[s,LOOPHOLE[i, REAL]];
IODefs.WriteLine[s];
IF NOT ks.endof[ks] THEN runFree ← FALSE;
IF NOT runFree THEN BEGIN
ch ← IODefs.ReadChar[];
IF ch = ’r THEN runFree ← TRUE;
IF ch = ’q THEN EXIT;
END;--IF
ENDLOOP;
ENDLOOP;
pgen.DestroyRandom[pgen];
END.--RandomTest