From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FREEMAIL_REPLYTO_END_DIGIT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6286c332c8cae43d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-25 17:53:09 PST From: Patrick Hohmeyer Subject: Re: Text_IO.End_Of_File Problem Newsgroups: comp.lang.ada Reply-To: pi3_1415926536@yahoo.ca References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8Bit User-Agent: KNode/0.3.2 Message-ID: Date: Sun, 25 Nov 2001 21:15:13 -0500 NNTP-Posting-Host: 65.94.177.24 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1006739226 65.94.177.24 (Sun, 25 Nov 2001 20:47:06 EST) NNTP-Posting-Date: Sun, 25 Nov 2001 20:47:06 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.direct.ca!look.ca!news1.tor.metronet.ca!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:16960 Date: 2001-11-25T21:15:13-05:00 List-Id: Hambut wrote : > Hi, > > I'm getting an exception with the attached code, and I can't see what > I'm doing wrong, or why it's falling over. > > The code basically: > > 1. Opens a file (sequential IO) > 2. Fills it with a sequence of Ascii.LF's and ASCII.CR's > 3. Closes it and reopens it as text_io > 4. reads each character in and outputs it's Ascii value to screen. > > Failure_Characters : constant String := ( 1 => Ascii.CR, > 2 => Ascii.CR, > 3 => Ascii.LF, > 4 => Ascii.CR, > 5 => Ascii.CR, > 6 => Ascii.LF, > 7 => Ascii.CR, > 8 => Ascii.LF ); In Ada.Text_IO an end_of_line equals CR LF (as in windows) So your file reads : CR, end_of_line, CR, end_of_line, end_of_line > What *seems* to be happening is that text_io.end_of_file is not > detecting the end of file properly in this case [or I've made some > elementary error (having spent lots of time correcting my errors up to > now I know which option my money's on :-)]. Get (Item : Character) skips all end_of_line's (and all end_of_page) and reads the first "normal" character. But end_of_file just tests the next character, so when the last character of your file is an end_of_line, an EOF test doesn't prevent Get (Item : Character) to skip the last end_of_line and depass the EOF. To get rid of this you must test for an end_of_line and when you encounter one, skip it with Skip_Line. Does this pointer helps, or do you want a corrected code? -- Patrick Hohmeyer