* Re: How to reset 'end_error' using text_io?
@ 1993-08-26 20:42 Dave Colla rd x7468
0 siblings, 0 replies; 6+ messages in thread
From: Dave Colla rd x7468 @ 1993-08-26 20:42 UTC (permalink / raw)
In <25h05c$3lv@neomimsy.cs.umd.edu> alex@cs.umd.edu (Alex Blakemore) writes:
>In article <fmoore.8@dseg.ti.com> fmoore@dseg.ti.com (Freeman L. Moore) writes
:
>> So, how can io_exceptions.end_error on standard input be cleared
>> permitting subsequent GETs to continue reading?
>text_io.skip_line I believe.
nope. end_error means end of file -- skip_line just skips to the
next line.
The following works, though vax specific:
open(file => f,mode => in_file, name => "SYS$OUTPUT");
loop
begin
get_line(f, buf, last);
put_line("got " & buf(1..last));
exception
when end_error =>
close(f);
open(file => f,mode => in_file, name => "SYS$OUTPUT");
end;
end loop;
instead of sys$output you could use text_io.name(text_io.standard_output)
which might be more portable
--Thor
dlc@ddsdx2.jhuapl.edu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to reset 'end_error' using text_io?
@ 1993-08-27 2:32 Michael Feldman
0 siblings, 0 replies; 6+ messages in thread
From: Michael Feldman @ 1993-08-27 2:32 UTC (permalink / raw)
In article <25h05c$3lv@neomimsy.cs.umd.edu> alex@cs.umd.edu (Alex Blakemore) wr
ites:
>In article <fmoore.8@dseg.ti.com> fmoore@dseg.ti.com (Freeman L. Moore) writes
:
>> 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).
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
students got burned by an incorrect example of mine, showing a handler
for End_Error that tried to keep going in the file. Tilt. I think the
upshot of the thread was that no solution will be portable.
Oh well.
Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman - co-chair, SIGAda Education Committee
Professor, Dept. of Electrical Engineering and Computer Science
The George Washington University - Washington, DC 20052 USA
202-994-5253 (voice) - 202-994-0227 (fax) - mfeldman@seas.gwu.edu (Internet)
"We just changed our CONFIG.SYS, then pressed CTRL-ALT-DEL. It was easy."
-- Alexandre Giglavyi, director Lyceum of Information Technologies, Moscow.
------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to reset 'end_error' using text_io?
@ 1993-08-27 3:01 dog.ee.lbl.gov!agate!spool.mu.edu!howland.reston.ans.net!europa.eng.gtefs
0 siblings, 0 replies; 6+ messages in thread
From: dog.ee.lbl.gov!agate!spool.mu.edu!howland.reston.ans.net!europa.eng.gtefs @ 1993-08-27 3:01 UTC (permalink / raw)
In article <fmoore.8@dseg.ti.com> fmoore@dseg.ti.com (Freeman L. Moore) writes:
> So, how can io_exceptions.end_error on standard input be cleared
> permitting subsequent GETs to continue reading?
then I replied
>text_io.skip_line I believe.
then Thor set me straight
> nope. end_error means end of file -- skip_line just skips to the next line.
OK, I was remembering using skip_line to solve a similar problem, when data_err
or
was raised on syntactically incorrect input using float_io.
Thor again:
> The following works, though vax specific:
> open(file => f,mode => in_file, name => "SYS$OUTPUT");
> loop
> begin
> get_line(f, buf, last);
> put_line("got " & buf(1..last));
> exception
> when end_error =>
> close(f);
> open(file => f,mode => in_file, name => "SYS$OUTPUT");
> end;
> end loop;
> instead of sys$output you could use text_io.name(text_io.standard_output)
you might even have better luck if you use sys$input or text_io.standard_input.
8^)
another thing to try would be to use
text_io.reset (text_io.standard_input)
instead of closing and reopening the file.
unfortunately, I don't have access to the great VAX compiler to test this out.
--
Alex Blakemore alex@cs.umd.edu NeXT mail accepted
--------------------------------------------------------------
"Without an engaged and motivated human being at the keyboard,
the computer is just another dumb box." William Raspberry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to reset 'end_error' using text_io?
@ 1993-08-27 12:50 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.
0 siblings, 0 replies; 6+ messages in thread
From: cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland. @ 1993-08-27 12:50 UTC (permalink / raw)
In <25jteg$6e7@neomimsy.cs.umd.edu> alex@cs.umd.edu (Alex Blakemore) writes:
>In article <fmoore.8@dseg.ti.com> fmoore@dseg.ti.com (Freeman L. Moore) writes
:
>> So, how can io_exceptions.end_error on standard input be cleared
>> permitting subsequent GETs to continue reading?
>then I replied
>>text_io.skip_line I believe.
>then Thor set me straight
>> nope. end_error means end of file -- skip_line just skips to the next line.
>
>OK, I was remembering using skip_line to solve a similar problem, when data_er
ror
>was raised on syntactically incorrect input using float_io.
>you might even have better luck if you use sys$input or text_io.standard_input
. 8^)
Oh. Of course.
>another thing to try would be to use
> text_io.reset (text_io.standard_input)
>instead of closing and reopening the file.
sorry Alex, but nope again. text_io.standard_input is a function
text_io.reset has one in_out parameter
and text_io.file_type is limited private so you can't play games with
storing text_io.standard_input into a variable and calling reset on
that variable.
>unfortunately, I don't have access to the great VAX compiler to test this out.
poor Alex. whatcha up to these days?
--Thor
dlc@ddsdx2.jhuapl.edu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to reset 'end_error' using text_io?
@ 1993-08-27 13:03 Dave Collard x7468
0 siblings, 0 replies; 6+ messages in thread
From: Dave Collard x7468 @ 1993-08-27 13:03 UTC (permalink / 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to reset 'end_error' using text_io?
@ 1993-08-27 15:22 Keith Shillington
0 siblings, 0 replies; 6+ messages in thread
From: Keith Shillington @ 1993-08-27 15:22 UTC (permalink / raw)
(Many educated and honorable persons) write:
>>> So, how can io_exceptions.end_error on standard input be cleared
>>> permitting subsequent GETs to continue reading?
(And many other elided conversations)
The problem being that
Text_IO.End_Of_File
has become true. This is equivalent to
Text_IO.End_Of_File(Current_Input)
-- originally defaulted to Text_IO.Standard_Input
So, lets assume that we have an F such that
F : Text_IO.File_Type;
If we are to
Text_IO.Open(F,Text_IO.In_Mode,"SYS$INPUT");
Text_IO.Set_Input(F);
Then the desired result is achieved. Of course for a more portable
solution, "SYS$INPUT" is replaced by a constant defined in a system
specific package...
--/*No Problem*/--
--
Keith Shillington /---------\ "No matter where you go,
email: shilling@source.ASSET.com /=======\ There you are."
voice: (619) 944-5134 /_____\ -- Buckaroo Banzaii
fax : (619) 944-7089 | | office: (301) 924-0050
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1993-08-27 15:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-08-27 3:01 How to reset 'end_error' using text_io? dog.ee.lbl.gov!agate!spool.mu.edu!howland.reston.ans.net!europa.eng.gtefs
-- strict thread matches above, loose matches on Subject: below --
1993-08-27 15:22 Keith Shillington
1993-08-27 13:03 Dave Collard x7468
1993-08-27 12:50 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.
1993-08-27 2:32 Michael Feldman
1993-08-26 20:42 Dave Colla rd x7468
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox