save expressions to a Maple repository - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Input and Output : File Manipulation : savelib

savelib - save expressions to a Maple repository

Calling Sequence

savelib(name1, name2, ...)

savelib(name1, name2, ..., filename)


name1, name2, ...


names of expressions to be saved



repository file name



Use the savelib command to save Maple expressions in a Maple repository. Procedures, modules, tables, and all other Maple data structures are saved in a .mla repository. Both the value and name are saved so that the assignment name := value can be retrieved in a later Maple session. After a name/value pair is saved to a library, the assignment name := value is automatically performed when the corresponding library is found in the library search path specified by libname.


All access to a Maple repository is via named expressions (that is, expressions assigned to names). Any Maple expression that is to be saved must be assigned to a name, and the name used in the call to savelib. Both the name and its assigned value are saved in the repository. For example, savelib( 2 ) is invalid, but t := 2; savelib( 't' ); saves the expression 2 under the name t.  Note that single uneval quotes are used around the parameter t in this example so that evaluation is delayed and the savelib command recognizes 't' instead of 2. Without these quotes, you will get an invalid input error indicating that, "savelib expects its 1st argument to be of type symbol, but received 2".


The file extension .mla is used to denote a Maple repository file.  In early versions of Maple, a repository was a pair of files named with .lib and .ind extensions. A repository is identified by specifying the full path of its .lib or .mla file. (For more information, see libname.) Specifying only a directory name identifies all repositories in the directory, of which the first writable repository will be used for saving.


If the .mla file specified by the filename parameter does not exist, it will be created using the command march(create,filename).  If attempting to save to the specified file fails, an error will occur (that is, it will not fall-back to savelibname or libname).


If the filename option is not used as the last argument in the call to savelib, one of the global variables savelibname or libname is used to determine the repository in which the expressions are saved. libname is only used if savelibname is not assigned. savelibname can be set to a string denoting the full path to a .mla file, or a string denoting the directory in which a .mla file exists, or, it can be a sequence of strings naming .mla files or directories.


For each directory in [savelibname] (or in [libname] if savelibname is not assigned), savelib attempts to open a Maple repository, for writing in the directory. If it is successful, it saves the values of name1, name2, ... and returns NULL. An error is raised if no repository in savelibname (or libname) can be opened for writing (for example, all the repositories are READONLY).


It is not recommended that you save to .mla files that are included with a Maple installation.  It is also not recommended that you save common names like x to a repository.  You may be surprised later in a subsequent session when x already has a value.


A repository can be written to only if it has a WRITABLE attribute. An attempt to write to a repository with a READONLY attribute raises an error. The WRITABLE and READONLY attributes of an archive can be examined and changed by using LibraryTools[WriteMode].

Thread Safety


The savelib command is thread-safe as of Maple 15.


For more information on thread safety, see index/threadsafe.


Save a value and a procedure to "mylib.mla" in the current directory.


sample_worker := proc(c) c+25 end proc:


Save to "mylib.mla" in the $MAPLE/lib directory which is automatically part of libname.  Variables saved will automatically get the saved value in subsequent sessions.


sample_worker := proc(c) c+25 end proc:









See Also

libname, LibraryTools, LibraryTools[Save], march, repository, repository,management, save

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam