Re: Writing to an external file?

*To*: mathgroup at smc.vnet.net*Subject*: [mg73376] Re: Writing to an external file?*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Wed, 14 Feb 2007 05:24:11 -0500 (EST)*Organization*: The Open University, Milton Keynes, UK*References*: <eqs9me$io1$1@smc.vnet.net>

laohu wrote: > > > When I run the lines below and write the outputs to the the file /trial12/, > > > > a=11+6 > > a>>trial12 > > Print ["The answer is ",a]>>>trial12 > > 17 > > The answer is 17 > > > > > > in /trial12/ I get the contents indicated below: > > > > 17 > > Null > > > > Whenever I write text or text+number combinations, I always get a null > string. Same problem with Export["filename.txt", a]. > > > > Can anyone tell me how to write a Print line or text to an external file? > > > Manipulating strings directly might achieve what you desire. (In[3] uses string concatenation, while In[4] reads the contents of the file from within Mathematica.) In[1]:= a=11+6 Out[1]= 17 In[2]:= a>>trial12 In[3]:= "The answer is "<>ToString[a]>>>trial12 In[4]:= !!trial12 From In[4]:= 17 "The answer is 17" Regards, Jean-Marc