In Maple, how do I save variables?

To save a variable in your current Maple session to a file, type the following at the Maple prompt:

  save varname, `filename.m`;

Replace varname with your variable name, and replace filename with the name of the file, keeping the .m extension. Also, be sure to use backquotes (`) rather than single quotes ('), which are used to delay evaluation. In some fonts, the two look nearly identical.

Note that the save command saves the variable as a Maple assignment statement. If the value of your variable depends on other variables, you will want to save them as well.

To save more than one variable, give all your variable names to the save command:

  save varname1, varname2, varname3, `filename.m`;

The save command no longer has a default that saves all variables. To save all your assigned variables, use the following code:

  parse(cat("save ", sprintf("%q", anames(user)), ", `filename.m`"), statement);  

You cannot edit a .m file, because it is saved in Maple internal format and is therefore not readable by users. You can, however, save an ASCII file (which can be edited) by saving it without the .m extension. Following are two examples:

  save varname1, `filename`;  
  save varname1, varname2, varname3, `filename`;

You can then read the file by entering at the Maple prompt:

  read `filename`;

Alternatively, you can edit the file with a text editor. You may need to provide the full path to the file.

To learn more, at the Maple prompt, enter:

  ?save

If you have questions about using statistical and mathematical software at Indiana University, contact Research Analytics. Research Analytics is located on the IU Bloomington campus at Woodburn Hall 200; staff are available for consultation Monday-Friday 9am-noon and by appointment.

This is document afpn in the Knowledge Base.
Last modified on 2015-05-20 00:00:00.

Contact us

For help or to comment, email the UITS Support Center.