I'd just like to say that I agree (to an extent) with both sides of the
argument here. In my opinion, Oberon/F supplies wonderfully flexible I/O
facilities, and I far prefer the I/O libraries to many other Oberon and
Modula-2 compilers I've evaluated and used in the past. On the other hand,
Oberon/F *should* probably have a module which behaves like Vinicius suggests
-- after all, using TextMappers and Converters and scanners and formatters is
too complicated for the casual programmer, and yet ObxAscii, In, and Out are
too simplistic (In & Out don't do ASCII, ObxAscii doesn't do real numbers).
I would suggest that Oberon Microsystems either extends ObxAscii with some
additional procedures (ReadReal, ReadLReal, WriteLReal, etc.), or adds an
'Ascii' module as part of the standard library for the benefit of the casual
programmer. Like Vinicius, I had to create my own ASCII I/O library, but
wasn't really embarrased about it because I was simply repackaging and
simplifying what's in TextMappers -- this is *far* from writing your own
ASCII I/O library from scratch!!!
We could certainly discuss an appropriate interface here -- the interface I
posted the other day was simply the one I implemented for myself in Oberon/F,
so it was not a suggestion for general purpose use. Perhaps Vinicius could
show us the ASCII I/O interface that he's already written? Here's one that I
would suggest based on something I did several years ago to hide the
complexity of the ISO Modula-2 I/O library:
---------------------------------------------------------------------------------------------------------------------------------------------
MODULE IO; (* ASCII I/O *)
TYPE
File;
VAR
done: BOOLEAN; (* readonly -- see comments below for applicable procs *)
PROCEDURE Create( VAR f: File; name: ARRAY OF CHAR ); (*done*)
PROCEDURE Open( VAR f: File; name: ARRAY OF CHAR ); (*done*)
PROCEDURE Reset( f: File ); (* position at start of file *)
PROCEDURE Close( VAR f: File );
PROCEDURE SetDefaultDir( path: ARRAY OF CHAR );
PROCEDURE SetInput( f: File );
PROCEDURE SetOutput( f: File );
PROCEDURE ReadCh( VAR ch: CHAR ); (*done*)
PROCEDURE ReadStr( VAR str: ARRAY OF CHAR ); (*done*)
PROCEDURE ReadLine( VAR str: ARRAY OF CHAR ); (*done*)(* read until next
EOL *)
PROCEDURE ReadInt( VAR i: INTEGER ); (*done*)
PROCEDURE ReadLInt( VAR i :LONGINT ); (*done*)
PROCEDURE ReadReal( VAR r: REAL ); (*done*)
PROCEDURE ReadLReal( VAR lr: LONGREAL ); (*done*)
PROCEDURE ReadLn; (*done*)
PROCEDURE WriteCh( ch: CHAR );
PROCEDURE WriteStr( str: ARRAY OF CHAR );
PROCEDURE WriteInt( i: INTEGER; width: INTEGER );
PROCEDURE WriteLInt( i: LONGINT; width: INTEGER );
PROCEDURE WriteReal( r: REAL; width, places: INTEGER );
PROCEDURE WriteLReal( lr: LONGREAL; width, places: INTEGER );
PROCEDURE WriteLn;
END IO.
---------------------------------------------------------------------------------------------------------------------------------------------
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...
-- Marc Martin, marc.martin@boeing.com