comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin D. Condic" <mcondic-nospam@quadruscorp.com>
To: Karlene <kejohnso@student.ecu.edu.au>
Subject: Re: Text Files
Date: 2000/05/23
Date: 2000-05-23T13:10:16+00:00	[thread overview]
Message-ID: <392AAC9F.8CF2287C@quadruscorp.com> (raw)
In-Reply-To: 8gdguu$f9v$1@news.cowan.edu.au

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]
======================================================================




  parent reply	other threads:[~2000-05-23  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-23  0:00 Text Files Karlene
2000-05-23  0:00 ` Robert Dewar
2000-05-24  0:00   ` Marin D. Condic
2000-05-23  0:00 ` Marin D. Condic [this message]
2000-05-23  0:00 ` Ted Dennison
2000-05-23  0:00 ` Cameron McShane
2000-05-23  0:00   ` John English
2000-05-23  0:00   ` tmoran
2000-05-23  0:00   ` Ted Dennison
2000-05-23  0:00   ` Marin D. Condic
2000-05-25  0:00     ` Cameron McShane
2000-05-25  0:00       ` Jean-Pierre Rosen
2000-05-26  0:00       ` Dale Stanbrough
2000-05-23  0:00 ` David Freshwater
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox