home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!walter!obry
- From: obry@flash.bellcore.com (Pascal Obry)
- Subject: Re: TEXT_IO.FILE_TYPE passing
- In-Reply-To: gt1827a@prism.gatech.EDU's message of 18 Aug 92 16:55:48 GMT
- Message-ID: <OBRY.92Aug18134623@cheesesteak.flash.bellcore.com>
- Sender: news@walter.bellcore.com
- Nntp-Posting-Host: cheesesteak.bellcore.com
- Organization: /u/obry/.organization
- References: <66292@hydra.gatech.EDU>
- Date: 18 Aug 92 13:46:23
- Lines: 48
-
-
- david,
-
- This is because FILE_TYPE is a limited private type and for these kind of type
- there is no assigment operator provided.
-
- So you should do something like this :
-
- procedure OPEN_OR_CREATE_FILE (THE_FILE : in out FILE_TYPE;
- THE_MODE : FILE_MODE := IN_FILE)
- FILE_NAME : STRING (80);
- INDEX : NATURAL := 0;
- begin
- PUT ("Input file name: ");
- GET_LINE (ITEM => FILE_NAME,
- LAST => INDEX);
- if THE_MODE = IN_FILE then
- OPEN (FILE => THE_FILE,
- MODE => IN_FILE,
- NAME => FILE_NAME (1 .. INDEX));
- else
- CREATE (FILE => THE_FILE,
- MODE => OUT_FILE,
- NAME => FILE_NAME (1 .. INDEX));
- end if;
- end OPEN_OR_CREATE_FILE;
-
- And now you can use it by :
-
- OPEN_OR_CREATE_FILE (THE_FILE => INPUT_FILE, THE_MODE => IN_FILE);
-
- About this read [LRM 7.4.4] ...
-
- I hope this help,
- Pascal.
- --
-
- -------------------------------------------------------------------------------
- -- Pascal OBRY --
- -- Room 2D-337 e_mail : obry@bellcore.com --
- -- Bellcore --
- -- 445 South Street voice : 1 - 201 829 4039 --
- -- Post Office Box 1910 --
- -- Morristown, New Jersey 07962-1910 --
- -------------------------------------------------------------------------------
-
- `` inheritance is surely a good answer, but who knows the question ? ''
-
-