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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a42a9e2a65b6a5c7 X-Google-Attributes: gid103376,public From: "Jeffrey D. Cherry" Subject: Re: Temporary files in Ada95. Date: 1999/03/26 Message-ID: <36FBB978.D44CF370@utech.net>#1/1 X-Deja-AN: 459398510 Content-Transfer-Encoding: 7bit References: <7dfrv7$gvv$1@nnrp1.dejanews.com> <7de1t6$usl$1@nnrp1.dejanews.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 922466966 202 (none) 206.61.179.85 Organization: Logicon Geodynamics MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-03-26T00:00:00+00:00 List-Id: Jeffrey, Look in the Ada95 manual that you reference in section A.8.2, paragraphs 2, 3, and 4. You will find the following: ---------- procedure Create(File : in out File_Type; Mode : in File_Mode := default_mode; Name : in String := ""; Form : in String := ""); Establishes a new external file, with the given name and form, and associates this external file with the given file. The given file is left open. The current mode of the given file is set to the given access mode. The default access mode is the mode Out_File for sequential and text input-output; it is the mode Inout_File for direct input-output. For direct access, the size of the created file is implementation defined. A null string for Name specifies an external file that is not accessible after the completion of the main program (a temporary file). A null string for Form specifies the use of the default options of the implementation for the external file. ---------- Except for case changes in the non-reserved words, and breaking up one paragraph into two, this quote from the Ada95 LRM is identical to section 14.2.1, paragraphs 2 and 3 of the Ada83 LRM. Using GNAT v3.11p, I tried the following: ---------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure For_Jeff is Temp_File : File_Type; Buffer : string(1..512); Last : natural; Saved_Name : Unbounded_String; begin -- For_Jeff Create(File => Temp_File, Mode => Out_File); Saved_Name := To_Unbounded_String(Name(Temp_File)); Put_Line("Temp file name is " & To_String(Saved_Name)); Put_Line(Temp_File, "This is a temporary file."); Reset(Temp_File, In_File); Get_Line(Temp_File, Buffer, Last); if Last in Buffer'range then Put_Line(Buffer(Buffer'first .. Last)); end if; Close(Temp_File); Put_Line("Attempting to open " & To_String(Saved_Name) & " ... "); begin Open(Temp_File, In_File, To_String(Saved_Name)); Put_Line("Opened file " & To_String(Saved_Name) & " successfully."); Close(Temp_File); exception when others => Put_Line("File was not opened successfully."); end; end For_Jeff; ---------- Running the above, I got the following output: ---------- Temp file name is D:\s3vvl40h This is a temporary file. Attempting to open D:\s3vvl40h ... Opened file D:\s3vvl40h successfully. ---------- The file does not exist after the program terminates as you would expect. The only odd thing I found is that the temporary file is created at the root directory of the current drive and not in the current directory of the current drive. I would have expected the file to be created in the current directory or in the system's TEMP directory. Regards, Jeffrey D. Cherry Logicon Geodynamics