Sample Maplet Application: Alert
This worksheet demonstrates how to write Maplet applications that function similarly to the Alert Maplet application available in the Maplets[Examples] package. It is designed for experienced Maple authors.
|
Simple Example
|
|
>
|
|
Invoke the Maplets Elements subpackage
>
|
|
Define the alert Maplet application; define an abnormal shutdown as one that returns FAIL.
>
|
|
Assign result to the value returned by the Maplet application.
>
|
|
|
|
Complex Example
|
|
The following example does not use any of the simplifications that have been included to make writing Maplet applications easier which leads to longer code but faster execution and for more complex Maplet applications, greater control of the Maplet application appearance and behavior. The required changes are:
1. An onstartup action must be specified. This action must be referenced and contain a RunDialog element which starts the AlertDialog element.
2. Actions associated with onapprove and oncancel must be given by a reference, and located outside the AlertDialog element. The command elements must be wrapped in Action elements.
3. All option names must be specified, including caption, reference, and value.
>
|
|
>
|
|
|
|
Comparison
|
|
Maplet applications can be viewed by using the Maplets[Tools][Print] function. This function prints the XML data structure of the Maplet application.
Compare the resulting output of the two example Maplet applications. Note that the only major difference is that the first example replaces the name references with strings where # is a unique number and the second example leaves the string references unchanged.
>
|
|
<Maplet abnormalshutdown='FAIL' locale='English_United States.1252' onstartup='Maplets_reference_12'>
<AlertDialog caption='Assuming x > 0 leads to a contradiction' enabled='true' onapprove='Maplets_reference_9' oncancel='Maplets_reference_10' reference='Maplets_reference_11' resizable='false' title='Warning: Contradiction' visible='true'/>
<Action reference='Maplets_reference_10' run='false'>
<Shutdown value='FAIL'/>
</Action>
<Action reference='Maplets_reference_9' run='false'>
<Shutdown value='true'/>
</Action>
<Action reference='Maplets_reference_12' run='false'>
<RunDialog dialog='Maplets_reference_11'/>
</Action>
</Maplet>
| |
>
|
|
<Maplet abnormalshutdown='FAIL' locale='English_United States.1252' onstartup='A0'>
<AlertDialog caption='Assuming x > 0 leads to a contradiction' enabled='true' onapprove='A1' oncancel='A2' reference='AD1' resizable='false' title='Warning: Contradiction' visible='true'/>
<Action reference='A0' run='false'>
<RunDialog dialog='AD1'/>
</Action>
<Action reference='A1' run='false'>
<Shutdown value='true'/>
</Action>
<Action reference='A2' run='false'>
<Shutdown value='FAIL'/>
</Action>
</Maplet>
| |
|
|
Maplets[Examples][Alert]
|
|
The Maplets[Examples][Alert] function displays a Maplet application similar to that of the previous examples. The function, however, allows the user to modify the caption and title options.
For help on this Maplet application, see:
>
|
|
To view the source code, enter:
>
|
|
| (4.1) |
>
|
|
|
Return to Index for Example Worksheets
|
Download Help Document
Was this information helpful?