[Oberon] SystemV - Integer2String, String2Integer

Jörg joerg.straube at iaeth.ch
Wed Jan 16 19:15:28 CET 2019


You can code the module "Convert" very similar to "Out".
Jörg

MODULE Convert;

IMPORT Texts;

VAR W: Texts.Writer;

PROCEDURE Copy(VAR s: ARRAY OF CHAR);
	VAR T: Texts.Text; R: Texts.Reader; ch: CHAR; i: INTEGER;
	BEGIN
		NEW(T); Texts.Open(T, ""); Texts.Append(T, W.buf);
Texts.OpenReader(R, T, 0);
		i := 0; WHILE ~R.eot DO Texts.Read(R, s[i]); INC(i) END;
s[i]:=0X
	END Copy;
	
PROCEDURE RealToStr(r: REAL; VAR s: ARRAY OF CHAR);
	BEGIN
		Texts.WriteRealFix(W, r, 7, 7); Copy(s)
	END RealToStr;
	
PROCEDURE IntToStr(i: LONGINT; VAR s: ARRAY OF CHAR);
	VAR W: Texts.Writer;
	BEGIN
		Texts.WriteInt(W, i, 0); Copy(s)
	END IntToStr;
	
BEGIN
	Texts.OpenWriter(W)
END Convert.Do

System.Free Convert ~




More information about the Oberon mailing list