With[..] not working with $Output
- To: mathgroup at smc.vnet.net
- Subject: [mg106325] With[..] not working with $Output
- From: dh <dh at metrohm.com>
- Date: Fri, 8 Jan 2010 04:17:05 -0500 (EST)
Hello,
does anybody have an idea why redirecting output using a With does not
work (version 7 Vista)?
Consider redefining the list $Output:
fun1 := (
old = $Output;
$Output = {OpenWrite["c:/tmp.txt"]};
Print["gaga"];
Close["c:/tmp.txt"];
$Output = old;)
fun1;
fun2 := With[{$Output = {OpenWrite["c:/tmp.txt"]}},
Print["123"];
Close["c:/tmp.txt"];
];
fun2;
Both functions f1 and f2 redefine $Output. fun1 works as expected, it
puts the output from Print in a file. fun2 on the contrary puts nothing
in the file, but writes the output to the screen. Therefore, "With"does
not work in this case.
Daniel
- Follow-Ups:
- Re: With[..] not working with $Output
- From: Leonid Shifrin <lshifr@gmail.com>
- Re: With[..] not working with $Output