>So, is something like *this* what you're looking for, Vinicius? This
>could be easily implemented using TextMappers and other stuff
>provided in the Oberon/F framework. It could even be implemented by
>someone here and posted on Guy's web page if Oberon Microsystems
>refuses to add it to Oberon/F.
Yes, this is exactly what I am expecting. The only problem is that
if OMI refuses to add something like this to Oberon/F, I will not
consider Oberon2 an option anymore. Please note that I am not
threatening OMI -- I am too weak for that. I firmly believe that if
OMI refuses to add simple ASCII text support, Oberon/F will follow the
same path of its predecessors, that is, it will never have a standard
ASCII text file I/O. The meaning of standard here is restricted only
within Oberon/F.
Here follows my own ASCII module. Please note that this was done
with a great help of many people around the world about one year ago,
when Oberon/F did not have a Strings module. I never really used it
because of the reasons stated above.
Could you please e-mail me yours?
Regards,
Vinicius
----------------------------------------------------------------------
MODULE Ascii; (* formatted IO for ASCII text files *)
IMPORT Files,Stores,Converters,TextModels,TextMappers,TextViews;
TYPE
Text* = POINTER TO
RECORD
new : BOOLEAN;
path,name : Files.Name;
form : TextMappers.Formatter;
scan : TextMappers.Scanner
END;
VAR
conv : Converters.Converter;
PROCEDURE OpenOld* ( VAR t : Text;
path,name : Files.Name );
VAR
loc : Files.Locator;
sto : Stores.Store;
BEGIN
loc := Files.dir.This(path);
Converters.Import(loc,name,conv,sto);
NEW(t);
t.new := FALSE;
t.path := path;
t.name := name;
t.scan.ConnectTo(sto(TextViews.View).ThisModel())
END OpenOld;
PROCEDURE OpenNew* ( VAR t : Text;
path,name : Files.Name );
BEGIN
NEW(t);
t.new := TRUE;
t.path := path;
t.name := name;
t.form.ConnectTo(TextModels.dir.New())
END OpenNew;
PROCEDURE Close* ( VAR t : Text );
VAR
loc : Files.Locator;
v : TextViews.View;
BEGIN
IF t.new THEN
loc := Files.dir.This(t.path);
v := TextViews.dir.New(t.form.rider.Base());
Converters.Export(loc,t.name,conv,v)
END;
t := NIL
END Close;
PROCEDURE Eot* ( VAR t : Text ) : BOOLEAN;
BEGIN
RETURN t.scan.rider.eot
END Eot;
PROCEDURE ReadLn* ( VAR t : Text );
VAR
c : CHAR;
BEGIN
REPEAT
t.scan.rider.ReadChar(c)
UNTIL t.scan.rider.eot OR (c = 0DX)
END ReadLn;
PROCEDURE ReadChar* ( VAR t : Text;
VAR x : CHAR );
BEGIN
t.scan.rider.ReadChar(x)
END ReadChar;
PROCEDURE ReadString* ( VAR t : Text;
VAR x : ARRAY OF CHAR );
BEGIN
t.scan.Scan;
COPY(t.scan.string,x)
END ReadString;
PROCEDURE ReadInt* ( VAR t : Text;
VAR x : INTEGER );
BEGIN
t.scan.Scan;
x := SHORT(t.scan.int)
END ReadInt;
PROCEDURE ReadLInt* ( VAR t : Text;
VAR x : LONGINT );
BEGIN
t.scan.Scan;
x := t.scan.int
END ReadLInt;
PROCEDURE ReadReal* ( VAR t : Text;
VAR x : REAL );
BEGIN
t.scan.Scan;
x := SHORT(t.scan.real)
END ReadReal;
PROCEDURE ReadLReal* ( VAR t : Text;
VAR x : LONGREAL );
BEGIN
t.scan.Scan;
x := t.scan.real
END ReadLReal;
PROCEDURE WriteLn* ( VAR t : Text );
BEGIN
t.form.WriteLn
END WriteLn;
PROCEDURE WriteChar* ( VAR t : Text;
x : CHAR );
BEGIN
t.form.WriteChar(x)
END WriteChar;
PROCEDURE WriteString* ( VAR t : Text;
x : ARRAY OF CHAR );
BEGIN
t.form.WriteString(x)
END WriteString;
PROCEDURE WriteLInt* ( VAR t : Text;
x : LONGINT;
w : INTEGER );
BEGIN
t.form.WriteIntForm(x,10,w," ",FALSE)
END WriteLInt;
PROCEDURE WriteLReal* ( VAR t : Text;
x : LONGREAL;
w : INTEGER );
BEGIN
t.form.WriteRealForm(x,w - 6,w,2," ")
END WriteLReal;
BEGIN
conv := Converters.list;
WHILE (conv # NIL) & (conv.fileType # "txt") DO
conv := conv.next
END
END Ascii.