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.0 required=5.0 tests=BAYES_00,FORGED_HOTMAIL_RCVD2, FREEMAIL_FROM autolearn=no 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.238.65 with SMTP id vi1mr6648865pbc.7.1339775743555; Fri, 15 Jun 2012 08:55:43 -0700 (PDT) Path: l9ni54089pbj.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: austin.obyrne@hotmail.com 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:54:19 -0700 (PDT) Organization: http://groups.google.com Message-ID: <7a50f5dd-429d-442d-8fb1-ae5532f5b0b3@googlegroups.com> References: <70866b0e-472c-4998-b081-51a15fc675dc@googlegroups.com> <9f016f9b-4a6f-4c64-894a-402979fbcfd9@googlegroups.com> NNTP-Posting-Host: 109.148.165.193 Mime-Version: 1.0 X-Trace: posting.google.com 1339775743 13141 127.0.0.1 (15 Jun 2012 15:55:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 15 Jun 2012 15:55:43 +0000 (UTC) In-Reply-To: <9f016f9b-4a6f-4c64-894a-402979fbcfd9@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=109.148.165.193; posting-account=pmkN8QoAAAAtIhXRUfydb0SCISnwaeyg User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-06-15T08:54:19-07:00 List-Id: On Friday, June 15, 2012 4:21:24 PM UTC+1, Adam Beneschan wrote: > 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 prog= ram: > >=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 .. OutNameLeng= th)); > >=20 > > Name given: UnsortedNumbers_n.dat=20 > >=20 > > Later on after some more computation in the same program I want to writ= e out to another external file of a different name and I use the same promp= t 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 .. OutNameLeng= th));=20 > >=20 > > Name given: SortedNumbers_n.dat=20 > >=20 > > Is this allowable?. > >=20 > > Your help would be greatly appreciated >=20 > Is there a good reason to use OutData for both files? I'd consider decla= ring a new File_Type object, Sorted_Out_Data or something (yes, I like putt= ing underscores in names), for the sorted output, and Unsorted_Out_Data (in= stead of OutData) for the unsorted output. The way you've written it, if y= ou use Create on OutData, and then Create again on the same OutData, you'll= get an exception unless you used Close on OutData in between. >=20 > Other than that, however, it's definitely allowable to write more than on= e text file from the same program, and to have multiple output text files o= pen at the same time. =20 >=20 > -- Adam Many thanks for your great help. Now that I know it is ok I would prefer to experiment separately getting it= to work with multi files rather than mess about here. There is some reaso= n also for not going down that road as an alternative at the moment but it'= s to do with the algorithm. It is very useful to know this now for future and I will perfect my skills = separately on another occasion. You have answered my question perfectly. I am developing some powerful Ada-friendly sort programs that I will be upl= oading later for general perusal of the readership. Regards and thanks again - adacrypt