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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,624c77c4e3ffaa2 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!c36g2000prc.googlegroups.com!not-for-mail From: deadlyhead Newsgroups: comp.lang.ada Subject: Re: Defaulting to Standard_Output Date: Thu, 23 Oct 2008 23:28:57 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <3a558b10-da3e-4dfa-93e1-573170dfa565@x1g2000prh.googlegroups.com> <7decfc0d-26ef-4539-8d2e-7e0bce88cfbd@r37g2000prr.googlegroups.com> <57dcc958-4b4c-4282-82b3-5c348895c6ad@b2g2000prf.googlegroups.com> <6JbMk.402762$yE1.46044@attbi_s21> NNTP-Posting-Host: 67.171.30.9 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1224829737 9319 127.0.0.1 (24 Oct 2008 06:28:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 24 Oct 2008 06:28:57 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c36g2000prc.googlegroups.com; posting-host=67.171.30.9; posting-account=snJuNwoAAABnc8T9lYkBlDQrDdSjOjG2 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092816 Iceweasel/3.0.1 (Debian-3.0.1-1),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2483 Date: 2008-10-23T23:28:57-07:00 List-Id: On Oct 23, 8:57=A0pm, "Jeffrey R. Carter" wrote: > deadlyhead wrote: > > > This is not what I want. =A0I want all output of the program to go to > > Standard_Output if no name is given for Outfile. =A0It's like if `cat` > > had an option '-o' that designated an output file. =A0`cat something.tx= t > > -o outfile.txt` =3D `cat something.txt > outfile.txt`, but `cat > > something.txt` outputs to the terminal. =A0That's the type of > > functionality that I want. > > It works like this: > > if File_Name /=3D "" then > =A0 =A0 Create (File); > =A0 =A0 Set_Output (File); > end if; > > -- call Put, Put_Line, and New_Line without a File parameter > > if File_Name /=3D "" then > =A0 =A0 Close (File); > end if; > > If the user specifies a file, then output goes to that file. If he doesn'= t, then > output goes to Standard_Output. > > -- > Jeff Carter > "When danger reared its ugly head, he bravely > turned his tail and fled." > Monty Python and the Holy Grail > 60 All right, now I feel like an idiot. That's pretty damn simple. I was thinking of it in terms of Scheme (which is really the only language that I've done serious file handling with). There, of course, there's no restriction on passing around references to stdout and the like, thus I could just (set! outfile (current-output-port)). The method you have been advocating makes a lot of sense. I'll be changing my code for that, then. Thanks! -- deadlyhead