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,913c345bb1f6b908 X-Google-Attributes: gid103376,public From: "Marin D. Condic" Subject: Re: Text Files Date: 2000/05/23 Message-ID: <392AAC9F.8CF2287C@quadruscorp.com>#1/1 X-Deja-AN: 626268671 Content-Transfer-Encoding: 7bit References: <8gdguu$f9v$1@news.cowan.edu.au> To: Karlene X-Sender: "Marin D. Condic" (Unverified) X-Server-Date: 23 May 2000 13:10:16 GMT Content-Type: text/plain; charset=us-ascii Organization: Quadrus Corporation Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-05-23T13:10:16+00:00 List-Id: Karlene wrote: > > How can you create a text file to be written to and read from (seperatley) > in an ada program where the file name is inputed from the user?? That depends on what you mean by "separately". A text file cannot be opened for read and write access simultaneously. You could first write the file and close it, then reopen the file for read access and read what you just wrote. As for getting the filename from the user, a filename is just a string. So you read the string using Text_IO from the standard input, perform whatever editing you need to do to the string, then use it as a parameter in the Open or Create procedures. You'll want to look at the Ada Reference Manual in the sections that deal with Text_IO for more detail. If you don't have a copy, try: http://www.adapower.com/ and look for the "Reference" button. On my web page under the Ada Programming subpage, you will find a bunch of small example programs I used to use in teaching an intro level Ada course. (Look for GNAT_Examples.chop) There are several small programs there which illustrate uses of Text_IO. The procedure calls you will want to look at in Ada.Text_IO are in Annex A: A.10.1 9 procedure Create (File : in out File_Type; Mode : in File_Mode := Out_File; Name : in String := ""; Form : in String := ""); 10 procedure Open (File : in out File_Type; Mode : in File_Mode; Name : in String; Form : in String := ""); 11 procedure Close (File : in out File_Type); Look over the explanations for these procedures and you'll likely be able to figure it out. MDC -- ====================================================================== Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m Visit my web site at: http://www.mcondic.com/ "I'd trade it all for just a little more" -- Charles Montgomery Burns, [4F10] ======================================================================