comp.lang.ada
 help / color / mirror / Atom feed
From: deadlyhead <deadlyhead@gmail.com>
Subject: Re: Defaulting to Standard_Output
Date: Thu, 23 Oct 2008 23:28:57 -0700 (PDT)
Date: 2008-10-23T23:28:57-07:00	[thread overview]
Message-ID: <dbfce6f1-b317-4f3d-8d3e-1df1c3c90458@c36g2000prc.googlegroups.com> (raw)
In-Reply-To: 6JbMk.402762$yE1.46044@attbi_s21

On Oct 23, 8:57 pm, "Jeffrey R. Carter"
<spam.jrcarter....@spam.acm.org> wrote:
> deadlyhead wrote:
>
> > This is not what I want.  I want all output of the program to go to
> > Standard_Output if no name is given for Outfile.  It's like if `cat`
> > had an option '-o' that designated an output file.  `cat something.txt
> > -o outfile.txt` = `cat something.txt > outfile.txt`, but `cat
> > something.txt` outputs to the terminal.  That's the type of
> > functionality that I want.
>
> It works like this:
>
> if File_Name /= "" then
>     Create (File);
>     Set_Output (File);
> end if;
>
> -- call Put, Put_Line, and New_Line without a File parameter
>
> if File_Name /= "" then
>     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



      reply	other threads:[~2008-10-24  6:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-23 23:10 Defaulting to Standard_Output deadlyhead
2008-10-24  0:16 ` Jeffrey R. Carter
2008-10-24  1:14   ` deadlyhead
2008-10-24  1:49     ` Adam Beneschan
2008-10-24  2:57       ` deadlyhead
2008-10-24  3:57         ` Jeffrey R. Carter
2008-10-24  6:28           ` deadlyhead [this message]
replies disabled

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