comp.lang.ada
 help / color / mirror / Atom feed
From: Mathias Dolidon <matd@netcourrier.com>
Subject: Re: Reading a text file
Date: 2000/10/08
Date: 2000-10-08T15:56:52+00:00	[thread overview]
Message-ID: <39E09A07.BFF0DA2C@netcourrier.com> (raw)
In-Reply-To: MPG.1449afb7d3cdd3a498968b@news.prodigy.net

stiletto@ryuji.net a �crit :
> 
> Hello All!
> 
> How can I read text file?  Following program is supposed to read a text
> file and print out the contents of the file, but I got following error
> messages.
> 
> Thanks in advance
> 
> test.adb:13:01: "Read" is not visible
> test.adb:13:01: non-visible (private) declaration at a-textio.ads:348
> test.adb:13:01: non-visible declaration at a-stream.ads:58
> gnatmake: "test.adb" compilation error
> 
> with Ada.Text_IO;
> use Ada.Text_IO;
> 
> procedure test is
> Data_File : File_Type;
> Result_File : File_Type;
> St : String(1..100);
> begin
> 
> Open(Data_File, In_File, "infile");
> 
> while not End_Of_File(Data_File) loop
>   Read(Data_File, St);
>   Put_Line(St);
> end loop;
> 
> end test;

Instead of "Read(Data_File, St)" write "Get_Line(Data_File, St)".

There's also another way to detecte the EOF :

--------
begin
loop
Get_Line(Data_File, St);
Put_Line(St);
end loop;

exception
  when end_error => close(Data_File);
end;
----------

Bye,
Mathias

-- 
http://www.mdlabs.ovh.org




  reply	other threads:[~2000-10-08  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-08  0:00 Reading a text file stiletto
2000-10-08  0:00 ` Mathias Dolidon [this message]
2000-10-08  0:00   ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2000-10-08  0:00 stiletto
2000-10-06  0:00 ` DPH
2000-10-06  0:00 ` DPH
replies disabled

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