How can I save, restore and export information with Maple?
On this page:
Overview
You can save and restore, and export Maple information in a number of ways. To save output from Maple (or later restore it) you have a number of choices:
Save
Use the 'save' command. "save filename" will write all assigned names in the current Maple session into the file specified by filename as a sequence of assignment statements. The complementary command for reading information is "read filename". If the filename ends with ".m" then the information is saved or read in "Maple internal format", otherwise the expressions are in readable text. To save ALL your variables in a ".m" file named "foo.m", just do the following at the Maple ">" prompt:
> save `foo.m`;
To only save a particular variable, say "a" for example, just do:
> save a, `foo.m`;
Saving worksheets
Use the "Save" or "Save As..." features from the File menu in the X version to save the current worksheet. This saves the commands you have typed and the results in "Maple worksheet" format with the extension ".mws". "Open" from the File menu will bring a worksheet file up without executing its contents; i.e., you will see the commands and results, but the variables aren't actually assigned. You can edit and execute the contents interactively (e.g., move to a line and hit Return), or execute the entire worksheet from to the Edit menu by choosing "Execute", then "Worksheet".
writeto
Use the 'writeto' routine. All the future commands will have their results stored in a file and will not be displayed on the screen. This command is not generally used interactively since you can lose control of the session; it is useful in writing Maple programs. To restore output to the screen, use:
> writeto(terminal);
The 'appendto' command works in the same fashion, except the file is appended to instead of overwritten.
The "Export" menu option
Use one of the "Export as" choices from the pull-down File menu:
- "Plain Text" saves the worksheet as a plain text dump.
- "Maple Text" saves the worksheet as specially marked text which distinguishes between comments, input, and output. You can then read in or paste from such a file, and Maple will interpret lines beginning with "> " as input, "# " as text, and ignore the rest (i.e., output lines). To read in the entire file, use File->Open; to paste, use Edit->Paste Maple Text.
- "LaTeX" generates a .tex file from the worksheet, with .eps files for any graphics.
(LaTeX generated by Maple may require some specific .sty files, namely maple2e.sty. As of Maple 10, these can be found in /mit/maple/maple_v10.0/distrib/etc/. You should add that path to your TEXINPUTS in order to correctly process Maple-generated LaTeX)
- "HTML" generates HTML from the worksheet, with .gif files for equations and graphics.
It currently does this with frames, generating a couple of extra pages and putting the GIFS into an image subdirectory.)
LaTeX export
In addition to exporting the entire worksheet as LaTeX (see above), Maple offers another method of formatting output in LaTeX math style. To display an expression in LaTeX math format type:
> latex(expression);
or:
> latex(expression, filename);
For example:
> latex(%); > latex((x^4 - y)/(y^2-3*x)); > latex(sin(x^2), `/mit/joeuser/maplestuff.tex`);
Other formats
There are also 'C' and 'fortran' functions which generate C or fortran code, and the 'eqn' command generates output for the troff/eqn processor. More information on the above Maple commands can be obtained by typing:
> ?commandname
or from the Help menu in the X version of Maple.