home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
coders
/
jËzyki_programowania
/
oberon
/
system
/
console.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1977-12-31
|
2KB
|
80 lines
Syntax10.Scn.Fnt
Syntax10b.Scn.Fnt
MODULE Console; (** cn, RD 26-May-96 *)
IMPORT Reals, HostSYS;
PROCEDURE Ch*(ch:CHAR);
VAR str: ARRAY 4 OF CHAR;
BEGIN
str[0]:=ch;
HostSYS.StdOut(str, 1)
END Ch;
PROCEDURE Str*(str: ARRAY OF CHAR);
i:INTEGER;
BEGIN
i:=0; WHILE str[i]#0X DO INC(i) END;
HostSYS.StdOut(str, i)
END Str;
PROCEDURE Ln*; BEGIN Ch(0AX) END Ln;
PROCEDURE Int*(x: LONGINT);
i: INTEGER; x0: LONGINT;
a: ARRAY 11 OF CHAR;
BEGIN i := 0;
IF x < 0 THEN
IF x = MIN(LONGINT) THEN Str(" -2147483648"); RETURN
ELSE x0 := -x
END
ELSE
x0 := x
END;
REPEAT
a[i] := CHR(x0 MOD 10 + 30H); x0 := x0 DIV 10; INC(i)
UNTIL x0 = 0;
Ch(" ");
IF x < 0 THEN Ch("-") END;
REPEAT DEC(i); Ch(a[i]) UNTIL i = 0
END Int;
PROCEDURE Hex*(x: LONGINT);
i: INTEGER; y: LONGINT;
a: ARRAY 10 OF CHAR;
BEGIN
i := 0; Ch(" ");
REPEAT y := x MOD 10H;
IF y < 10 THEN a[i] := CHR(y + 30H) ELSE a[i] := CHR(y + 37H) END;
x := x DIV 10H; INC(i)
UNTIL i = 8;
REPEAT DEC(i); Ch(a[i]) UNTIL i = 0
END Hex;
PROCEDURE Bool*(b: BOOLEAN);
BEGIN
IF b THEN Str(" TRUE") ELSE Str(" FALSE") END
END Bool;
PROCEDURE Real*(x: LONGREAL); (* Texts.WriteLongReal *)
CONST maxD = 16;
VAR e, n: INTEGER; x0: LONGREAL;
d: ARRAY maxD OF CHAR;
BEGIN
n:=8;
e := Reals.ExpoL(x);
IF e = 0 THEN
Str(" 0");
ELSIF e = 2047 THEN
Str(" NaN");
ELSE
Ch(" ");
IF x < 0 THEN Ch("-"); x := -x END;
e := SHORT(LONG(e - 1023) * 77 DIV 256);
IF e >= 0 THEN x := x / Reals.TenL(e) ELSE x := Reals.TenL(-e) * x END ;
IF x >= 10.0D0 THEN x := 0.1D0 * x; INC(e) END ;
x0 := Reals.TenL(n-1); x := x0*x + 0.5D0;
IF x >= 10.0D0*x0 THEN x := 0.1D0 * x; INC(e) END ;
Reals.ConvertL(x, n, d);
DEC(n); Ch(d[n]); Ch(".");
REPEAT DEC(n); Ch(d[n]) UNTIL n = 0;
Ch("D");
IF e < 0 THEN Ch("-"); e := -e ELSE Ch("+") END;
Ch(CHR(e DIV 100 + 30H)); e := e MOD 100;
Ch(CHR(e DIV 10 + 30H));
Ch(CHR(e MOD 10 + 30H))
END Real;
END Console.