Re: Save print in textfile
- To: mathgroup at smc.vnet.net
- Subject: [mg15564] Re: [mg15528] Save print in textfile
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Tue, 26 Jan 1999 13:44:44 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
If you must use Print you can do the following. You can open a new streem with temp=OpenAppend["textfile.txt"] You can then append this new streem to the $Output channel with AppendTo[$Output,temp] Now whenever you use Print, what you print will be saved in the file textfile.txt. By default InputForm is used but you can explicitly write Print[OutputForm["dog"]] to get dog rather than "dog" in your text file. However, I would never use this sort of low level stuff, its much too complicated! Instead of using Print["sample: ",name] and so on you can just evaluate a string, say v="sample"<>ToString[name]<>"\r"<>"________"<>"conditions:"<>ToString[num ber] and so on and save it to a file with OutputForm[v]>>textfile.txt (You should combine this with SetDirectory[] if you want to save your file in a different directory from the one you are working in). On Mon, Jan 18, 1999, wgrebe <wgrebe at cityweb.de> 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 cityweb.de > Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp/ http://eri2.tuins.ac.jp/