home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / ada / 2380 < prev    next >
Encoding:
Text File  |  1992-08-18  |  1.9 KB  |  62 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!walter!obry
  3. From: obry@flash.bellcore.com (Pascal Obry)
  4. Subject: Re: TEXT_IO.FILE_TYPE passing
  5. In-Reply-To: gt1827a@prism.gatech.EDU's message of 18 Aug 92 16:55:48 GMT
  6. Message-ID: <OBRY.92Aug18134623@cheesesteak.flash.bellcore.com>
  7. Sender: news@walter.bellcore.com
  8. Nntp-Posting-Host: cheesesteak.bellcore.com
  9. Organization: /u/obry/.organization
  10. References: <66292@hydra.gatech.EDU>
  11. Date: 18 Aug 92 13:46:23
  12. Lines: 48
  13.  
  14.  
  15. david,
  16.  
  17. This is because FILE_TYPE is a limited private type and for these kind of type
  18. there is no assigment operator provided.
  19.  
  20. So you should do something like this :
  21.  
  22.    procedure OPEN_OR_CREATE_FILE (THE_FILE : in out FILE_TYPE;
  23.                   THE_MODE : FILE_MODE := IN_FILE)
  24.       FILE_NAME : STRING (80);
  25.       INDEX     : NATURAL := 0;
  26.       begin
  27.          PUT ("Input file name:  ");
  28.          GET_LINE (ITEM => FILE_NAME,
  29.                    LAST => INDEX);
  30.          if THE_MODE = IN_FILE then
  31.             OPEN (FILE => THE_FILE,
  32.                   MODE => IN_FILE,
  33.                   NAME => FILE_NAME (1 .. INDEX));
  34.          else
  35.             CREATE (FILE => THE_FILE,
  36.                     MODE => OUT_FILE,
  37.                     NAME => FILE_NAME (1 .. INDEX));
  38.          end if;
  39.       end OPEN_OR_CREATE_FILE;
  40.  
  41. And now you can use it by :
  42.  
  43.       OPEN_OR_CREATE_FILE (THE_FILE => INPUT_FILE, THE_MODE => IN_FILE);
  44.  
  45. About this read [LRM 7.4.4] ...
  46.  
  47. I hope this help,
  48. Pascal.
  49. --
  50.  
  51. -------------------------------------------------------------------------------
  52. --  Pascal OBRY                                     --
  53. --  Room 2D-337                e_mail : obry@bellcore.com           --
  54. --  Bellcore                                     --
  55. --  445 South Street            voice : 1 - 201 829 4039         --
  56. --  Post Office Box 1910                             --
  57. --  Morristown, New Jersey 07962-1910                         --
  58. -------------------------------------------------------------------------------
  59.  
  60.   `` inheritance is surely a good answer, but who knows the question ? ''
  61.  
  62.