Creating and Displaying Maplet Applications in Command-Line Maple - Maple Programming Help

Home : Support : Online Help : Programming : Maplets : Maplets/CommandLine

Creating and Displaying Maplet Applications in Command-Line Maple

 You can use the Command-Line version of Maple to create and display Maplet applications.

Description

 • To use Maplet applications in the Command-Line version, enter the Maplet application code at the Maple prompt as you would for Maple code.
 • Alternatively, using a text editor, enter a Maplet application definition into a text file.  Save the text file with a .mpl extension.
 Depending on your operating system, you can run the .mpl file by:
 * Double-clicking it from your file browser or
 * Entering maple and the filename as an argument at the command line.
 The Maple code is executed in Command-Line Maple. If a Maplet application is defined with the Maplet[Display] command specified, it is displayed.

Examples

Copy the following Maplet application code into your Command-Line session.  Press ENTER.

 > $\mathrm{with}\left(\mathrm{Maplets}[\mathrm{Elements}]\right):$
 > $\mathrm{maplet}≔\mathrm{Maplet}\left(\left["Click a Button:",\left[\mathrm{Button}\left("OK",\mathrm{Shutdown}\left("true"\right)\right),\mathrm{Button}\left("Cancel",\mathrm{Shutdown}\left(\right)\right)\right]\right]\right):$
 > $\mathrm{result}≔\mathrm{Maplets}[\mathrm{Display}]\left(\mathrm{maplet}\right)$

Save the following example as a .mpl file.  From your file browser, double-click the .mpl file you created.

 > $\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{Maplets}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{Elements}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{maplet}≔\mathrm{Maplet}\left(\mathrm{Window}\left('\mathrm{title}'="Hilbert Matrix",\left[\left["Dimension:",\mathrm{TextField}['\mathrm{TB1}']\left("10"\right)\right],\left["Target format:",\mathrm{DropDownBox}['\mathrm{DDB1}']\left(\left["MATLAB","MatrixMarket","delimited"\right]\right)\right],\left["File name:",\mathrm{TextField}['\mathrm{TB2}']\left("hilmat"\right)\right],\left[\mathrm{Button}\left("OK",\mathrm{Shutdown}\left(\left['\mathrm{TB1}','\mathrm{DDB1}','\mathrm{TB2}'\right]\right)\right),\mathrm{Button}\left("Cancel",\mathrm{Shutdown}\left(\right)\right)\right]\right]\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use};\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{result}≔\mathrm{Display}\left(\mathrm{maplet}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use}:$$\mathbf{if}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{result}\ne \left[\right]\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{and}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{result}}_{3}\ne ""\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{try}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}n≔\mathrm{parse}\left({\mathrm{result}}_{1}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end try};\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{type}\left(n,'\mathrm{integer}'\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{ExportMatrix}\left({\mathrm{result}}_{3},\mathrm{LinearAlgebra}:-\mathrm{HilbertMatrix}\left(n,\mathrm{outputoptions}=\left['\mathrm{datatype}'=\mathrm{float}[8]\right]\right),'\mathrm{target}'=\mathrm{convert}\left({\mathrm{result}}_{2},'\mathrm{symbol}'\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end if}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end if}:$