Question: formatting the output generated by writeto(filename)

I capture the output of dsolve after setting infolevel to some file so I can later read that output and put it in my own document (Latex).

Currently what I do is set infolevel, then use writeto(file_name) to send all the output that would normally go to standard output to the text file, then later do readline to read it back for further processing.

The problem is that Maple does not put the output in the file the same way as it appears on the screen when using worksheet.

For example, all newlines are lost. So everything comes out in one line in the file_name .  I am not sure why that is.

Is there an option or trick to make the output not lose the newlines? It also seems to format things differently in the file. An example will make this clear

When running this code

currentdir("... set the directory to where you want to save the file to ..");

writeto("output_of_dsolve.txt");  #send all output to file
writeto(terminal); #to send output back to terminal

When I open the file output_of_dsolve.txt this is what shows

`Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`     solAssignyApplyFunction(x)equalsuminus0cosApplyFunction(x) + _C1, [

       Typesetting:-mprintslash([sol := y(x) = -cos(x) + _C1], 

       [y(x) = -cos(x) + _C1])]


But in the worksheet, when I run the same code without writeto("output_of_dsolve.txt");  so output goes to terminal as normal, here it is how it looks like

Is there a way to keep the newlines? And why there is some extra stuff in the file that do not show on the screen? Should one change the Settings for Display before doing the above? Currently the default I have is typesetting level is "Extended". Do not know if this affects it or not.

Is the above method the only way to capture the output of dsolve from infolevel to a text file? It looks like Maple uses `` in the file in place where there should be a newline (CR) inserted.


I did this experiment but there is still some strange formatting coming out in the file. Here is an example



interface(typesetting=standard): #added this
interface(prettyprint=0):  #added this


And now the text file has this

`Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`Typesetting:-mprintslash([(sol := y(x) = -cos(x)+_C1)],[y(x) = -cos(x)+_C1])

What is Typesetting:-mprintslash at the end of the line above? it is duplicate.

And how to get rid of it? Is there another settings to set other than interface(typesetting=standard): and interface(prettyprint=0): ?

Please Wait...