comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: function Is_Open (File : File_Type) return Boolean; :Text_io
Date: Mon, 26 Oct 2015 11:02:03 -0700
Date: 2015-10-26T11:02:03-07:00	[thread overview]
Message-ID: <n0lpmp$nd4$1@dont-email.me> (raw)
In-Reply-To: <75dd21a2-9265-44e4-a4d4-e2d96ffdecb1@googlegroups.com>

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


  parent reply	other threads:[~2015-10-26 18:02 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26 10:00 function Is_Open (File : File_Type) return Boolean; :Text_io comicfanzine
2015-10-26 11:27 ` Simon Wright
2015-10-26 13:25   ` comicfanzine
2015-10-26 18:01     ` Simon Wright
2015-10-26 19:03       ` AdaMagica
2015-10-27 11:30         ` Simon Wright
2015-10-26 18:02     ` Jeffrey R. Carter [this message]
2015-10-26 13:28   ` comicfanzine
2015-10-26 15:07     ` Jacob Sparre Andersen
2015-10-26 16:37     ` AdaMagica
2015-10-26 20:46     ` J-P. Rosen
2015-10-27  8:42   ` comicfanzine
2015-10-27 11:34     ` Simon Wright
2015-10-28 13:32       ` comicfanzine
2015-10-27  8:51   ` comicfanzine
2015-10-27 17:15     ` Jeffrey R. Carter
2015-10-26 22:48 ` Bob Duff
2015-10-27  8:30   ` Dmitry A. Kazakov
2015-10-27 13:30     ` Bob Duff
2015-10-27 14:00       ` G.B.
2015-10-27 15:26       ` Dmitry A. Kazakov
2015-10-27 16:43         ` G.B.
2015-10-27 20:04           ` Dmitry A. Kazakov
2015-10-28 11:06             ` Georg Bauhaus
2015-10-28 17:58               ` Randy Brukardt
2015-10-28 18:20               ` Dmitry A. Kazakov
2015-10-28 20:36                 ` Bob Duff
2015-10-28 21:02                   ` Dmitry A. Kazakov
2015-10-29 11:25                     ` AdaMagica
2015-10-29 13:37                       ` Dmitry A. Kazakov
2015-10-29 17:57                         ` AdaMagica
2015-10-29 18:12                           ` AdaMagica
2015-10-29 18:26                           ` Dmitry A. Kazakov
2015-10-30  8:27                           ` Jacob Sparre Andersen
2015-10-30  9:11                             ` J-P. Rosen
2015-10-29 11:47                 ` G.B.
2015-10-29 13:01                   ` J-P. Rosen
2015-10-29 14:00                   ` Dmitry A. Kazakov
2015-10-30  1:06                     ` Georg Bauhaus
2015-10-30  8:39                       ` Dmitry A. Kazakov
2015-10-30 14:32                         ` G.B.
2015-10-30 16:20                           ` Dmitry A. Kazakov
2015-10-30 19:07                             ` G.B.
2015-10-31  9:31                               ` Dmitry A. Kazakov
2015-10-31 11:17                                 ` Georg Bauhaus
2015-10-30 14:40                         ` G.B.
2015-10-30 16:26                           ` Dmitry A. Kazakov
2015-10-28 20:07         ` Bob Duff
2015-10-28 20:59           ` Dmitry A. Kazakov
2015-10-27 14:02     ` G.B.
2015-10-27 15:10       ` Dmitry A. Kazakov
2015-10-27 16:41         ` G.B.
replies disabled

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