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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,69101b88c05a1b3f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.220.230 with SMTP id pz6mr6540883pbc.3.1339773803479; Fri, 15 Jun 2012 08:23:23 -0700 (PDT) Path: l9ni54000pbj.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: =?windows-1252?Q?Re=3A_Can_I_Do_this_=96_Help_Badly_Needed=2E?= Date: Fri, 15 Jun 2012 08:21:24 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9f016f9b-4a6f-4c64-894a-402979fbcfd9@googlegroups.com> References: <70866b0e-472c-4998-b081-51a15fc675dc@googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1339773803 25494 127.0.0.1 (15 Jun 2012 15:23:23 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 15 Jun 2012 15:23:23 +0000 (UTC) In-Reply-To: <70866b0e-472c-4998-b081-51a15fc675dc@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-06-15T08:21:24-07:00 List-Id: On Friday, June 15, 2012 6:06:12 AM UTC-7, austin...@hotmail.com wrote: > I want to write to two external files in turn from within the same progra= m: >=20 > This is the first prompt, >=20 > Ada.Text_IO.Put > (Item =3D> " Please enter the name of the unsorted file >"); > Ada.Text_IO.New_Line(2); > Ada.Text_IO.Put > (Item =3D> " Call it UnSortedNumberFile_n.dat - for whatever 'n' may be= >"); > Ada.Text_IO.New_Line(2); > Ada.Text_IO.Put(Item =3D> " "); > Ada.Text_IO.Get_Line(Item =3D> OutFileName,Last =3D> OutNameLength); > Ada.Text_IO.New_Line(2); > Ada.Text_IO.Create(File =3D> OutData, > Mode =3D> Ada.Text_IO.Out_File,Name =3D> OutFileName(1 .. OutNameLength= )); >=20 > Name given: UnsortedNumbers_n.dat=20 >=20 > Later on after some more computation in the same program I want to write = out to another external file of a different name and I use the same prompt = again that is only only slightly changed in the names. >=20 > Second prompt. >=20 > Ada.Text_IO.Put > (Item =3D> " Please enter the name of the unsorted file >"); > Ada.Text_IO.New_Line(2); > Ada.Text_IO.Put > (Item =3D> " Call it SortedNumberFile_n.dat - for whatever 'n' may be >= "); > Ada.Text_IO.New_Line(2); > Ada.Text_IO.Put(Item =3D> " "); > Ada.Text_IO.Get_Line(Item =3D> OutFileName,Last =3D> OutNameLength); > Ada.Text_IO.New_Line(2); > Ada.Text_IO.Create(File =3D> OutData, > Mode =3D> Ada.Text_IO.Out_File,Name =3D> OutFileName(1 .. OutNameLength= ));=20 >=20 > Name given: SortedNumbers_n.dat=20 >=20 > Is this allowable?. >=20 > Your help would be greatly appreciated Is there a good reason to use OutData for both files? I'd consider declari= ng a new File_Type object, Sorted_Out_Data or something (yes, I like puttin= g underscores in names), for the sorted output, and Unsorted_Out_Data (inst= ead of OutData) for the unsorted output. The way you've written it, if you= use Create on OutData, and then Create again on the same OutData, you'll g= et an exception unless you used Close on OutData in between. Other than that, however, it's definitely allowable to write more than one = text file from the same program, and to have multiple output text files ope= n at the same time. =20 -- Adam