comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Re: Trouble w/ End_Error exception in Integer_Text_IO
Date: 1997/06/18
Date: 1997-06-18T00:00:00+00:00	[thread overview]
Message-ID: <01bc7c33$c23a2ca0$LocalHost@xhv46.dial.pipex.com> (raw)
In-Reply-To: 33a4a1c5.2804336@netnews.worldnet.att.net




Ha Ha X <kql6708@is.nyu.edu> wrote in article
<33a4a1c5.2804336@netnews.worldnet.att.net>...
> I've been having a lot of trouble with an irritating feature of
> Ada.Integer_Text_IO's End_Error exception. When using the Get()
> procedure, if the user enters a manual EOF from the keyboard (^D in
> Unix, or ^Z in DOS), Get() raises End_Error. This is, I suppose,
> intended to prevent people from reading past EOF in a text file. Fine.
[...]

A possible solution is to use Get_Immediate instead of Get, and write a
little procedure which accumulates characters into a string and then uses
the integer version of Get on the string. Line buffering still works under
GNAT for DOS (because it doesn't disable DOS' line buffering (which it
should!)), but, of course, it may not under other environments or Adas.

What Adas for DOS should all offer is an open option (via the Form
parameter) which disables EOF character detection for a text input stream
(other kinds of EOF detection unaffected), and this should be the default
for standard input (there is no tradition of using ^Z to terminate user
input under DOS, as there is (using ^D) under UNIX).

Such an option isn't workable for UNIX (I think) because the kernel
converts the ^D into a 'hard' EOF (read returns 0). There could always be
an option to ignore EOF altogether (but never as a default).

Perhaps a better solution is to simply accept that ^Z or ^D raises an
exception, and to handle that exception as a way for the user to forcefully
terminate the program (or similar). Or you could just tell your users not
to press ^Z!

Nick.





  parent reply	other threads:[~1997-06-18  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-16  0:00 Trouble w/ End_Error exception in Integer_Text_IO Ha Ha X
1997-06-16  0:00 ` john schneider
1997-06-18  0:00 ` Nick Roberts [this message]
1997-06-20  0:00   ` Do-While Jones
1997-06-21  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox