MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Save print in textfile

  • To: mathgroup at
  • Subject: [mg15556] Re: Save print in textfile
  • From: Emmanuel.Peccoud at (Emmanuel Peccoud)
  • Date: Tue, 26 Jan 1999 13:44:38 -0500 (EST)
  • Organization: e-NoteBooks Ltd.
  • References: <7814h5$>
  • Sender: owner-wri-mathgroup at

wgrebe <wgrebe at> wrote:

> Hallo,
> I want to save the result of a series of Print commands in a textfile.
> For example:
> df=Do[
> Print["sample: ",name];
> Print["___________________________________"]; Print[" conditions: "
> number];
> Print["___________________________________"]; ];
> results in the output:
> sample: aab
> ___________________________________
> conditions: 34
> ___________________________________
> This output I want to have in the file "textfile.txt" in the directory
> C:\temp.
> Thank you
>                             Witold
> wgrebe at

Print is directed to the $Output stream. You can redefine this stream to
a file of your choice. 

$Output = OpenWrite["C:\\temp\\ textfile.txt", FormatType -> OutputForm]

This command redirects $Output to a file named "textfile.txt" in the
temp directory.



Print whatever you need. Print each item will be placed on a new line.

Close at $Output

Don't forget to close the stream when you are done. This can easily be
integrated in a package.

You could achieve similar results using the Put instruction (>>) which
would save you the hassle of opening and closing the stream.

I hope this helps.
Emmanuel Peccoud
e-Notebooks Ltd.
Visit our web site at

  • Prev by Date: Re: Special characters
  • Next by Date: Re: Save print in textfile
  • Previous by thread: Re: Save print in textfile
  • Next by thread: Re: Save print in textfile