comp.lang.ada
 help / color / mirror / Atom feed
From: Mats Weber <matsw@mail.com>
Subject: Re: End_Of_File does not work as expected...
Date: 2000/11/26
Date: 2000-11-26T00:00:00+00:00	[thread overview]
Message-ID: <3A218E36.709F71BE@mail.com> (raw)
In-Reply-To: 3A218010.819FFAC5@acm.org

Jeff Carter wrote:

> The UNIX echo command echoes its command line arguments, IIRC. The
> questioner does not appear to be writing an equivalent program. I am not
> sure what he is trying to accomplish.

Sorry, I meant cat, not echo.

> > while not End_Of_File loop
> >    while not End_Of_Page loop
> >       while not End_Of_Line loop
> >          Get(c);
> >          Put(c);
> >       end loop;
> >       Skip_Line;   -- can be omitted.
> >       New_Line;
> >    end loop;
> >    Skip_Page;   -- can be omitted.
> >    New_Page;
> > end loop;
> 
> If the code does not skip line terminators, then it will raise
> End_Error. If the file does not contain page terminators, this code will
> raise End_Error. When reading from the keyboard, End_Of_File is usually
> always False.

No, it won't raise End_Error in either case, because Get(Character)
starts by skipping any number of line and page terminators and returns
the first character after them. It will only raise End_Error if a file
terminator is after the sequence of line and page terminators.

> My advice would be to use a Get_Line function and Put_Line, and have a
> handler for End_Error.

Agreed.




      reply	other threads:[~2000-11-26  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-24 23:42 End_Of_File does not work as expected Mika Fischer
2000-11-25  5:14 ` Jeff Carter
2000-11-25  0:00   ` Mika Fischer
2000-11-25  0:00     ` Jeff Carter
2000-11-26  0:00 ` Mats Weber
2000-11-26  0:00   ` Jeff Carter
2000-11-26  0:00     ` Mats Weber [this message]
replies disabled

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