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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: function Is_Open (File : File_Type) return Boolean; :Text_io Date: Tue, 27 Oct 2015 10:15:14 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <8508dafc-5fea-4e5d-992f-8fe48f5d9df6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 27 Oct 2015 17:13:05 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="caa759af2a9c666aec02942f6fe5abd6"; logging-data="12598"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sRX2npcVeFM7Fenp+TwE8fWK1Zi4AKVA=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <8508dafc-5fea-4e5d-992f-8fe48f5d9df6@googlegroups.com> Cancel-Lock: sha1:e+xowBIQLCYYSHP2qEEusYipzuA= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:28080 Date: 2015-10-27T10:15:14-07:00 List-Id: I've reformatted your code to my coding standards. with Ada.Text_IO; use Ada.Text_IO; procedure Testfichier is Monfichier : File_Type; begin Create (Monfichier, Name => "clone.adb"); -- If Create succeeds, then Monfichier is open and you get to the "if". If -- Create fails, it raises an exception and your program ends. if Is_Open (Monfichier) then -- If you get to this line, then Create succeeded and Monfichier if open, so -- this test is redundant; Is_Open will always return True. Put (Item => "Le fichier , ouvert ? : ", File => Monfichier); end if; -- You probably want to close the file before you end. end Testfichier; So your code is functionally equivalent to with Ada.Text_IO; use Ada.Text_IO; procedure Testfichier is Monfichier : File_Type; begin Create (Monfichier, Name => "clone.adb"); Put (Item => "Le fichier , ouvert ? : ", File => Monfichier); end Testfichier; Since you want it to output the result of Is_Open, and we know that will always be True, and we should close the file, I'd end up with with Ada.Text_IO; procedure Testfichier is Monfichier : Ada.Text_IO.File_Type; begin Ada.Text_IO.Create (File => Monfichier, Name => "clone.adb"); Ada.Text_IO.Put_Line (Item => "Le fichier , ouvert ? : True", File => Monfichier); Ada.Text_IO.Close (File => Monfichier); end Testfichier; -- Jeff Carter "You cheesy lot of second-hand electric donkey-bottom biters." Monty Python & the Holy Grail 14