1987-08-19 18:07:01 +00:00
|
|
|
(*$R-*)
|
1987-05-13 14:36:45 +00:00
|
|
|
IMPLEMENTATION MODULE RealInOut;
|
|
|
|
|
|
|
|
IMPORT InOut;
|
1987-05-22 17:15:09 +00:00
|
|
|
IMPORT RealConversions;
|
1987-06-26 15:59:52 +00:00
|
|
|
IMPORT Traps;
|
1987-05-22 17:15:09 +00:00
|
|
|
FROM SYSTEM IMPORT WORD;
|
1987-05-13 14:36:45 +00:00
|
|
|
|
1987-05-22 17:15:09 +00:00
|
|
|
CONST MAXNDIG = 32;
|
|
|
|
MAXWIDTH = MAXNDIG+7;
|
|
|
|
TYPE RBUF = ARRAY [0..MAXWIDTH+1] OF CHAR;
|
1987-05-13 14:36:45 +00:00
|
|
|
|
|
|
|
PROCEDURE WriteReal(arg: REAL; ndigits: CARDINAL);
|
1987-05-22 17:15:09 +00:00
|
|
|
VAR buf : RBUF;
|
|
|
|
ok : BOOLEAN;
|
1987-05-13 14:36:45 +00:00
|
|
|
|
|
|
|
BEGIN
|
1987-05-22 17:15:09 +00:00
|
|
|
IF ndigits > MAXWIDTH THEN ndigits := MAXWIDTH; END;
|
|
|
|
IF ndigits < 10 THEN ndigits := 10; END;
|
1987-10-19 10:06:24 +00:00
|
|
|
RealConversions.RealToString(arg, ndigits, -INTEGER(ndigits - 7), buf, ok);
|
1987-05-13 14:36:45 +00:00
|
|
|
InOut.WriteString(buf);
|
|
|
|
END WriteReal;
|
|
|
|
|
|
|
|
PROCEDURE ReadReal(VAR x: REAL);
|
1987-05-22 17:15:09 +00:00
|
|
|
VAR Buf: ARRAY[0..512] OF CHAR;
|
|
|
|
ok: BOOLEAN;
|
1987-05-13 14:36:45 +00:00
|
|
|
|
|
|
|
BEGIN
|
|
|
|
InOut.ReadString(Buf);
|
1987-05-22 17:15:09 +00:00
|
|
|
RealConversions.StringToReal(Buf, x, ok);
|
1987-06-23 17:12:42 +00:00
|
|
|
IF NOT ok THEN
|
1987-06-26 15:59:52 +00:00
|
|
|
Traps.Message("real expected");
|
|
|
|
HALT;
|
1987-06-23 17:12:42 +00:00
|
|
|
END;
|
|
|
|
Done := TRUE;
|
1987-05-13 14:36:45 +00:00
|
|
|
END ReadReal;
|
|
|
|
|
1987-05-22 17:15:09 +00:00
|
|
|
PROCEDURE wroct(x: ARRAY OF WORD);
|
|
|
|
VAR i: CARDINAL;
|
|
|
|
BEGIN
|
|
|
|
FOR i := 0 TO HIGH(x) DO
|
|
|
|
InOut.WriteOct(CARDINAL(x[i]), 0);
|
|
|
|
InOut.WriteString(" ");
|
|
|
|
END;
|
|
|
|
END wroct;
|
|
|
|
|
1987-05-13 14:36:45 +00:00
|
|
|
PROCEDURE WriteRealOct(x: REAL);
|
|
|
|
BEGIN
|
1987-05-22 17:15:09 +00:00
|
|
|
wroct(x);
|
1987-05-13 14:36:45 +00:00
|
|
|
END WriteRealOct;
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
Done := FALSE;
|
|
|
|
END RealInOut.
|