Re: ASCII text file module

Marc Martin (marc.martin@kauai.ds.boeing.com)
26 Aug 1996 10:02:24 -0800

Subject: Re: ASCII text file module

> Is Oberon/F intended only for computer science experts? I am a civil
> engineer and my concerns are far away from having to code my own ASCII
> text file I/O module.
>
> Are ASCII text files an obsolete concept?
>
> Could you please illumine my spirit about these Great Questions?

My 2 cents...

I'm an aerospace engineer and I would also not like to bother with writing my
own ASCII text file I/O module, but unfortunately I see it as a neccessary
evil which I've been doing for years (ever since I switched from Pascal to
Modula-2). In fact, in order to protect myself from all the various
"flavors" of Modula-2 (and now Oberon-2) libraries, I created my own library
of ASCII I/O, math, string handling, etc. calls. This way, when I port from
one compiler to another, (theoretically) most of the effort is spent porting
the library, then everything else remains more or less the same.

The Interface of the ASCII I/O portion of my Win Oberon/F library looks like
this:

(* ASCII file handling *)

PROCEDURE FileCreate (VAR f: File; fileSpec: ARRAY OF CHAR);
PROCEDURE FileOpen (VAR f: File; fileSpec: ARRAY OF CHAR);
PROCEDURE FileOpenFocus (VAR f: File);
PROCEDURE FileOpenLocNameType (VAR f: File; loc: Files.Locator; name:
Files.Name;
type: Files.Type);
PROCEDURE FileClose (VAR f: File);
PROCEDURE FileDelete (fileName: Files.Name);
PROCEDURE FileRename (oldName, newName: Files.Name);
PROCEDURE FileGetName (f: File; VAR fileName: ARRAY OF CHAR);
PROCEDURE FileReread (f: File);
PROCEDURE FileRewrite (f: File);
PROCEDURE FileView (VAR f: File);

(* ASCII file reading *)

PROCEDURE RdSetFile (f: File);
PROCEDURE RdLook (VAR ch: CHAR);
PROCEDURE RdCh (VAR ch: CHAR);
PROCEDURE RdStr (VAR str: ARRAY OF CHAR);
PROCEDURE RdLine (VAR line: ARRAY OF CHAR);
PROCEDURE RdIdent (VAR str: ARRAY OF CHAR);
PROCEDURE RdInt (VAR int: LONGINT);
PROCEDURE RdReal (VAR real: LONGREAL);
PROCEDURE RdLn;
PROCEDURE RdDone (): BOOLEAN;

(* ASCII file writing *)

PROCEDURE WrSetFile (f: File);
PROCEDURE WrCh (ch: CHAR);
PROCEDURE WrChs (ch: CHAR; times: LONGINT);
PROCEDURE WrStr (str: ARRAY OF CHAR);
PROCEDURE WrStrW (str: ARRAY OF CHAR; width: LONGINT);
PROCEDURE WrQStr (str: ARRAY OF CHAR); (* quoted *)
PROCEDURE WrInt (int: LONGINT);
PROCEDURE WrIntW (int, width: LONGINT);
PROCEDURE WrRealP (real: LONGREAL; places: LONGINT);
PROCEDURE WrRealW (real: LONGREAL; width: LONGINT);
PROCEDURE WrRealWP (real: LONGREAL; width, places: LONGINT);
PROCEDURE WrSp (times: LONGINT); (* space *)
PROCEDURE WrLn;
PROCEDURE WrLns (times: LONGINT);

This probably doesn't qualify as a "real" ASCII I/O library, but it suits my
personal needs. And although I may not like having to implement something
that probably should have been done by the compiler writers themselves, I
think it's probably better than having to switch to C++... :-)

--
Marc Martin, marc.martin@boeing.com