comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!math.ohio-state.edu!sol.ctr.columbia.edu!caen!saimiri. primate.wisc.edu!aplcen.apl.jhu.edu!ddsdx2.jhuapl.edu!dlc@ucbvax.Berkeley.EDU   (Dave Collard x7468)
Subject: Re: How to reset 'end_error' using text_io?
Date: 27 Aug 93 13:03:47 GMT	[thread overview]
Message-ID: <1993Aug27.130347.3911@aplcen.apl.jhu.edu> (raw)

In <1993Aug27.023237.20864@seas.gwu.edu> mfeldman@seas.gwu.edu (Michael Feldman
) writes:

>In article <25h05c$3lv@neomimsy.cs.umd.edu> alex@cs.umd.edu (Alex Blakemore) w
rites:
>>In article <fmoore.8@dseg.ti.com> fmoore@dseg.ti.com (Freeman L. Moore) write
s:
>>> So, how can io_exceptions.end_error on standard input be cleared
>>> permitting subsequent GETs to continue reading?
>>
>>text_io.skip_line I believe.
>>-- 
>Would that it were (portably) so. Trouble is, that the End_Error was
>raised because you bumped into EOF, which has a nasty tendency of causing
>the file to be closed. And since you can't reopen Standard_Input, you
>are stuck, at least in my experience (your implementation mileage may
>vary).

Hmmm.  you cant reopen standard_input, but you can reopen a file with
the same name as it (see below);

>My guess is that if you really need to do this, you could open the
>file as a named file associated with the device. Then you could (maybe)
>Reset it. We had this discussion on the net about a year ago when my

So is my solution portable??  anyone who can try it on their machines?
it works on the VAX:

with text_io; 
procedure enderror is
  buf : string(1..80); last : natural;
  f : text_io.file_type;
begin
  text_io.open(file => f,
               mode => text_io.in_file, 
               name => text_io.name(text_io.standard_input));
  text_io.set_input(f);
  loop
    begin
      text_io.get_line(buf, last);
      text_io.put_line("got " & buf(1..last));
    exception
      when text_io.end_error => 
        text_io.reset(f);
    end;
  end loop;
end;

thanks to R_Tim_Coslet@cup.portal.com for suggesting reset(f)
instead of close(f), open(...)

thanks to Alex Blakemore for pointing out that i was getting
the name of standard_output instead of input (which was
the same on the vax normally)

--Thor
dlc@ddsdx2.jhuapl.edu

             reply	other threads:[~1993-08-27 13:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-27 13:03 Dave Collard x7468 [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-08-27 15:22 How to reset 'end_error' using text_io? Keith Shillington
1993-08-27 12:50 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.
1993-08-27  3:01 dog.ee.lbl.gov!agate!spool.mu.edu!howland.reston.ans.net!europa.eng.gtefs
1993-08-27  2:32 Michael Feldman
1993-08-26 20:42 Dave Colla rd x7468
replies disabled

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