I recently wanted to use FilePrint
to print the contents somewhere else but in the notebook I was using. However, the obvious-seeming solution doesn't work at all:
In[137]:= temp = With[{str = OpenWrite[]},
Block[{$Output = str},
Print["fee fi fo fum"]];
Close[str]];
In[138]:= FilePrint[temp]
"fee fi fo fum"
In[139]:= With[{str=OpenWrite[]},
Block[{$Output = str},
FilePrint[temp]];
Close[str]];
"fee fi fo fum"
Since the obvious solution doesn't work, does anybody know a less obvious solution, preferably one that doesn't involve re-implementing FilePrint
myself? Sure, that would be easy, but I'd prefer not to do it.