comp.lang.ada
 help / color / mirror / Atom feed
* Is this explanation correct?
@ 2001-06-29 21:54 chris.danx
  2001-06-30  0:30 ` Jeffrey Carter
  0 siblings, 1 reply; 2+ messages in thread
From: chris.danx @ 2001-06-29 21:54 UTC (permalink / raw)


Hi,

The ps-programming@tutoraid.org mailing list seems a little dead at the minute
and it seems like the Ada folk are busy (I am no expert and don't want to
perpetuate misinformation).


A newbie posted asking

"There is something I don't understand about
end_of_file stuff. When I key in my data on the file in the floppy drive, if
I leave and save a space after the end data, I will get an End_Error . but
when I open the file back, and get rid of that space and save, and run the
program it works fine. can you tell me why?"


I want to check this before I relay it to the mailing list.


The program uses Ada.Integer_text_io which ignores spaces, so when the program
get's to the space it thinks there's an integer after it and it doesn't find
one, so it generates the end_error (exception) to let us know.


Is this correct?

Cheers,
Chris




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is this explanation correct?
  2001-06-29 21:54 Is this explanation correct? chris.danx
@ 2001-06-30  0:30 ` Jeffrey Carter
  0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey Carter @ 2001-06-30  0:30 UTC (permalink / raw)


"chris.danx" wrote:
> 
> A newbie posted asking
> 
> "There is something I don't understand about
> end_of_file stuff. When I key in my data on the file in the floppy drive, if
> I leave and save a space after the end data, I will get an End_Error . but
> when I open the file back, and get rid of that space and save, and run the
> program it works fine. can you tell me why?"
> 
> I want to check this before I relay it to the mailing list.
> 
> The program uses Ada.Integer_text_io which ignores spaces, so when the program
> get's to the space it thinks there's an integer after it and it doesn't find
> one, so it generates the end_error (exception) to let us know.
> 
> Is this correct?

It might be better to say that, with the space at the end of the file,
Ada.Integer_Text_IO.Get will stop before the space, so End_Of_File will
return False. Then the next call to Ada.Integer_Text_IO.Get will read
past the end of file looking for an Integer, causing End_Error to be
raised. With the space removed, Ada.Integer_Text_IO.Get will stop before
the line/page/file terminator, so End_Of_File will return True, and the
program will terminate normally.

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-06-30  0:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-29 21:54 Is this explanation correct? chris.danx
2001-06-30  0:30 ` Jeffrey Carter

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