home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / ada / 3786 < prev    next >
Encoding:
Text File  |  1992-12-21  |  3.2 KB  |  97 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!caen!uvaarpa!software.org!smithd
  3. From: smithd@software.org (Doug Smith)
  4. Subject: Re: I/O and the LRM
  5. Message-ID: <1992Dec21.163435.22675@software.org>
  6. Keywords: I/O NAME OPEN
  7. Sender: usenet@software.org (Usenet News/Mail Support)
  8. Organization: Software Productivity Consortium, Herndon, Virginia
  9. References: <206@hathor.CSS.GOV>
  10. Date: Mon, 21 Dec 1992 16:34:35 GMT
  11. Lines: 84
  12.  
  13. In article <206@hathor.CSS.GOV> jeffe@hathor.CSS.GOV (Jeff Etrick) writes:
  14. >  The following is taken from the LRM:
  15. > >>function NAME(FILE : in FILE_TYPE) return STRING;
  16. > >>Returns a string which uniquely identifies the external file currently
  17. > >>associated with the given file (and may thus be used in an OPEN
  18. > >>operation).  If an environment allows alternative specifications of the
  19. > >>name (for example, abbreviations), the string returned by the function
  20. > >>should correspond to a full specification of the name.
  21. > >>The exception STATUS_ERROR is raised if the given file is not open.
  22. >  I have used the function successfully many times to get the external
  23. > name of a currently opened file but what I don't understand is the
  24. > comment about it being used in an open statement. Why would I want to use
  25. > this statement in an open since the file must already be opened or
  26. > STATUS_ERROR will be raised.
  27. > Thanks for the help,
  28. > Jeff
  29.  
  30. It will take a while to answer your question...
  31.  
  32. In one application, I found that a temporary file would be useful.
  33. When I discovered that Ada allowed you to create temporary files,
  34. I quickly used this new-found expertise:
  35.  
  36.     Create (Temp, Out_File);
  37.  
  38. Of course, my next lesson was quite disheartening:
  39.  
  40.     -- Much information written to file.
  41.     ...
  42.        Temp_Name : constant String := Name (Temp);
  43.     begin
  44.        Close (Temp); -- Temp is deleted from system!
  45.        Send_Name_To_Sub_Process (Temp_Name);
  46.  
  47. Yes, as soon as the temporary file is closed, it
  48. was deleted--and not by the system.  I could not use
  49. temporary files to pass data to a subprocess.
  50. (Will this behavior still be allowed in Ada9X?)
  51. AI-00046/06-ra-WJ states:
  52.     1)  An implementation is allowed to delete a temporary file
  53.         immediately after closing it.
  54.  
  55. Yet, the feature that was so beneficial was that a system
  56. dependent name was available!  So now:
  57.  
  58.       Create (Temp, Out_File)
  59.       declare
  60.          Temp_Name : constant String := Name (Temp);
  61.       begin
  62.          Close (Temp); -- Temp is deleted from system!
  63.          ...
  64.          Create (Temp, Out_File, Get_Temp_Name);
  65.  
  66.          -- Much information written to file.
  67.  
  68.          Close (Temp); -- Temp not deleted!
  69.          Send_Name_To_Sub_Process (Temp_Name);
  70.  
  71. THEN, THE OTHER PROCESS CAN PERFORM AN OPEN USING THE
  72. STRING FROM A NAME FUNCTION.  Yes, this is convoluted
  73. and not necessarily applicable to a single Ada program
  74. which could be redesigned to use the RESET feature--
  75. but you asked for it!
  76.  
  77. However, this is still a system dependent feature, because
  78. the same AI states:
  79.  
  80.     2)  The NAME function is allowed to raise USE_ERROR if
  81.         its argument is associated with an external file
  82.         that has no name, in particular, a temporary file.
  83.  
  84. Oh, well.
  85.  
  86. Doug Smith
  87. smithd@software.org
  88.