[Date Index] [Thread Index] [Author Index]
Re: Writing to an external file?
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 uses string concatenation, while In reads the contents of the file from within Mathematica.) In:= a=11+6 Out= 17 In:= a>>trial12 In:= "The answer is "<>ToString[a]>>>trial12 In:= !!trial12 From In:= 17 "The answer is 17" Regards, Jean-Marc