comp.lang.ada
 help / color / mirror / Atom feed
From: comicfanzine@gmail.com
Subject: Re: End of a file
Date: Mon, 18 Jan 2016 23:20:52 -0800 (PST)
Date: 2016-01-18T23:20:52-08:00	[thread overview]
Message-ID: <ffda9608-9be0-4b0f-8746-d9a2382babbb@googlegroups.com> (raw)
In-Reply-To: <687cd6fa-bf75-4892-b74e-d3ad381d8612@googlegroups.com>

>If you have 30 lines, set_line (30) is OK. It's >set_Line (31) that raises End_Error... 

Ok , then why it's the case here :
" raised ADA.IO_EXCEPTIONS.END_ERROR : a-textio.adb:1900 "

There is only 26 lines , and the loop is suppose to stop at the end of the file . 

WITH Ada.Text_IO ;  USE Ada.Text_IO ;

Procedure count_nb_lines is

  this_file : File_type ;

  Last_line : Positive_Count := 1 ;

Begin

    Open
     (File => this_file ,
      Mode => In_file ,
      Name => "count_nb_lines.adb");

   loop exit when End_Of_File( this_file );
     skip_line( this_file , Last_line );

     Last_line := Last_line + 1 ;
   end loop ;

   put ( "Total of lines by Ada.Text_IO' s package : "&Positive_Count'Image( Last_line ) );

   Close( this_file );

end count_nb_lines ;


  parent reply	other threads:[~2016-01-19  7:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19  5:11 End of a file comicfanzine
2016-01-19  5:52 ` J-P. Rosen
2016-01-19  7:20 ` comicfanzine [this message]
2016-01-19  8:02   ` Georg Bauhaus
2016-01-19  8:43 ` comicfanzine
2016-01-19  8:44   ` MM
2016-01-20  1:16 ` comicfanzine
replies disabled

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