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: Mon, 26 Oct 2015 11:02:03 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <75dd21a2-9265-44e4-a4d4-e2d96ffdecb1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 26 Oct 2015 17:59:55 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="caa759af2a9c666aec02942f6fe5abd6"; logging-data="23972"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nn/mHwhym4M/GxueXhWSEy0DiqItQvC0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <75dd21a2-9265-44e4-a4d4-e2d96ffdecb1@googlegroups.com> Cancel-Lock: sha1:jMM9sSNRS70W5Xn4XVnqqjrOURw= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:28059 Date: 2015-10-26T11:02:03-07:00 List-Id: On 10/26/2015 06:25 AM, comicfanzine@gmail.com wrote: > Thanks fot link . > > I want to create+open a file then use Is_Open , if the file have been create i want to put some text + the value of Is_Open(should be TRUE) . > > There is french in the code : > > [code]WITH Ada.Text_IO ; USE Ada.Text_IO ; > > PROCEDURE TestFichier IS > > MonFichier : File_type ; > > BEGIN > Create( MonFichier,Name => "clone.adb"); > open(MonFichier,In_file,"clone.adb") ; Create leaves the file open; you don't need to Open it after Create. In fact, Open should raise Status_Error if the file is already open. See ARM A.8.2 http://www.adaic.org/resources/add_content/standards/12rm/html/RM-A-8-2.html > if Is_Open(MonFichier) and MonFichier = true Monfichier is of private type Ada.Text_IO.File_Type, and True, since you have not defined it yourself, is of type Boolean. Since you have not defined "=" for these 2 types, the comparison on the right of "and" will not compile. What you want is probably if Is_Open (Monfichier) then [Note that Ada is case insensitive, and many of us will reformat your code for easier reading, converting CamelCase to Camelcase in the process. This is partly why CamelCase is not recommended for Ada, where the common usage is to separate words with underlines, giving Mon_Fichier. Ada is also designed to read, as much as possible, as English text, so using identifiers in another language is not a good idea.] > then put("Le fichier , ouvert ? : ",MonFichier); This also won't compile: There is no Put visible that takes a String as its 1st parameter and a File_Type as its 2nd. Using named notation will let you put the parameters in any order you like, and make the code easier to read: Put (Item => "Le fichier , ouvert ? : ", File => Monfichier); > end if; > END TestFichier ;[/code] > -- Jeff Carter "I'm a kike, a yid, a heebie, a hook nose! I'm Kosher, Mum! I'm a Red Sea pedestrian, and proud of it!" Monty Python's Life of Brian 77