MPL - Maple Help

Maple Language File (.mpl) Format

MPL file format

Description

 • MPL (Maple Language File) is a text-based file format for Maple programs.
 • MPL files are simply text files containing statements conforming to the syntax of the Maple language. These are the same as statements that can be entered interactively.
 • MPL files can be executed from within Maple using the read statement.
 • The commands in a Maple worksheet can be exported to MPL format using the Export as Maple Input menu option.
 • The Export command can also export Maple expressions and programs to this format.

Examples

Write Maple commands to an MPL script in the home directory of the current user.

 > $\mathrm{mplFile}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left["myscript.mpl"\right],\mathrm{base}=\mathrm{homedir}\right)$
 ${"/Users/JohnSmith/myscript.mpl"}$ (1)
 > $\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{WriteFile}\left(\mathrm{mplFile},\mathrm{cat}\left("n := 20;\n","evalf\left[n\right]\left(Pi\right);\n"\right)\right):$
 > $\mathbf{read}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{mplFile}$
 ${n}{≔}{20}$
 ${3.1415926535897932385}$ (2)

Export a Maple expression to an MPL file and read it back.

 > $\mathrm{expr}≔\mathrm{CurveFitting}:-\mathrm{Spline}\left(\left[\left[0,1.124\right],\left[1,2.2322\right],\left[2,3.343\right],\left[3,2.334\right]\right],v,\mathrm{degree}=1\right)$
 ${\mathrm{expr}}{≔}\left\{\begin{array}{cc}{1.124}{+}{1.1082}{}{v}& {v}{<}{1}\\ {1.1214}{+}{1.1108}{}{v}& {v}{<}{2}\\ {5.361}{-}{1.009}{}{v}& {\mathrm{otherwise}}\end{array}\right\$ (3)
 > $\mathrm{mplFile}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left["piecewise.mpl"\right],\mathrm{base}=\mathrm{homedir}\right)$
 ${"/Users/JohnSmith/piecewise.mpl"}$ (4)
 > $\mathrm{Export}\left(\mathrm{mplFile},\mathrm{expr}\right)$
 ${68}$ (5)
 > $\mathbf{read}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{mplFile}$
 $\left\{\begin{array}{cc}{1.124}{+}{1.1082}{}{v}& {v}{<}{1}\\ {1.1214}{+}{1.1108}{}{v}& {v}{<}{2}\\ {5.361}{-}{1.009}{}{v}& {\mathrm{otherwise}}\end{array}\right\$ (6)