MathGroup Archive 2010

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

Search the Archive

With[..] not working with $Output



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




  • Prev by Date: Re: algebraic numbers
  • Next by Date: Lists of Equations
  • Previous by thread: Print Registration Marks
  • Next by thread: Re: With[..] not working with $Output