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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,dfe1c08e956f971a X-Google-Attributes: gid103376,public From: Mathias Dolidon Subject: Re: Reading a text file Date: 2000/10/08 Message-ID: <39E09A07.BFF0DA2C@netcourrier.com>#1/1 X-Deja-AN: 678978329 Content-Transfer-Encoding: 8bit References: X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@wanadoo.fr X-Trace: wanadoo.fr 971020612 13263 193.250.91.229 (8 Oct 2000 15:56:52 GMT) Organization: Wanadoo, l'internet avec France Telecom Mime-Version: 1.0 NNTP-Posting-Date: 8 Oct 2000 15:56:52 GMT Newsgroups: comp.lang.ada Date: 2000-10-08T15:56:52+00:00 List-Id: 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