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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6286c332c8cae43d,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-25 14:42:56 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: hfrumblefoot@yahoo.com (Hambut) Newsgroups: comp.lang.ada Subject: Text_IO.End_Of_File Problem Date: 25 Nov 2001 14:42:56 -0800 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 62.188.130.64 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1006728176 11699 127.0.0.1 (25 Nov 2001 22:42:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 25 Nov 2001 22:42:56 GMT Xref: archiver1.google.com comp.lang.ada:16956 Date: 2001-11-25T22:42:56+00:00 List-Id: 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. 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 :-)]. I'd appreciate it if someone on here could have a peer at this and give me a pointer as to where I'm going wrong. The output I get from executing the code is: " 13 13 raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:394 " Thanks in advance for any help. Cheers, Hambut. =====Code Follows====== with Text_Io; with Ada.Sequential_Io; procedure Eof_Fails is package Io is new Ada.Sequential_Io( Character ); Test_File_Name : constant String := "Test_fails"; Sequential_File : Io.File_Type; Text_File : Text_Io.File_Type; 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 ); -- These seem to work OK. -- Failure_Characters : constant String := ( 1 => Ascii.CR, -- 2 => Ascii.CR, -- 3 => Ascii.LF, -- 4 => Ascii.CR ); C : Character; begin -- First set up the test file -- Io.Create( File => Sequential_File, Name => Test_File_Name ); for I in Failure_Characters'First..Failure_Characters'Last loop Io.Write( File => Sequential_File, Item => Failure_Characters(I) ); end loop; Io.Close( File => Sequential_File ); -- Now try and read in as a text file -- Text_Io.Open( File => Text_File, Mode => Text_Io.In_File, Name => Test_File_Name ); while not Text_Io.End_Of_File( File => Text_File ) loop Text_Io.Get( File => Text_File, Item => C ); Text_Io.Put_Line( Integer'Image( Character'Pos(C))); end loop; Text_Io.Close( File => Text_File ); exception when others => Text_Io.Close( File => Text_File ); raise; end Eof_fails;