Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
Sample Maplet Application: Confirm
This worksheet demonstrates how to write Maplet applications that function similarly to the Confirm Maplet application available in the Maplets[Examples] package. It is designed for experienced Maple authors.
Simple Example
restart:
# Invoke the Maplets Elements subpackage. with(Maplets[Elements]): # Define the confirm Maplet application. Define an abnormal # shutdown as one that returns FAIL. maplet1 := Maplet( 'abnormalshutdown' = "FAIL", ConfirmDialog( # The text that appears as the confirm Maplet application's # message and title. "Assuming x > 0 leads to a contradiction", 'title' = "Warning: Contradiction", # The value returned. Click "Yes", true. # Click "No", false. Click "Cancel", FAIL. 'onapprove' = Shutdown( "true" ), 'ondecline' = Shutdown( "false" ), 'oncancel' = Shutdown( "FAIL" ) ) ):
# Assign result to the value returned by the Maplet application. result := parse(Maplets[Display](maplet1));
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 ConfirmDialog element.
2. Actions associated with onapprove, ondecline, and oncancel must be given by a reference, and located outside the ConfirmDialog element. The command elements must be wrapped in Action elements.
3. All option names must be specified, including caption, reference, and value.
with(Maplets[Elements]): # Define the "onstartup" option referenced by A0. maplet2 := Maplet( 'abnormalshutdown' = "FAIL", 'onstartup' = 'A0', ConfirmDialog( 'reference' = 'AD1', 'caption' = "Assuming x > 0 leads to a contradiction", 'title' = "Warning: Contradiction", 'onapprove' = 'A1', 'ondecline' = 'A2', 'oncancel' = 'A3' ), # Starts the ConfirmDialog. Action( 'reference' = 'A0', RunDialog( 'dialog' = 'AD1' ) ), # Define the resulting action if "Yes" is clicked. Action( 'reference' = 'A1', Shutdown( 'value' = "true" ) ), # Define the resulting action if "No" is clicked. Action( 'reference' = 'A2', Shutdown( 'value' = "false" ) ), # Define the resulting action if "Cancel" is clicked. Action( 'reference' = 'A3', Shutdown( 'value' = "FAIL" ) ) ):
result := parse(Maplets[Display](maplet2));
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 in the first example replaces the name references with "_Maplets_reference_#" strings where # is a unique number and the second example leaves the string references unchanged.
Maplets[Tools][Print](maplet1);
Maplets[Tools][Print](maplet2);
Maplets[Examples][Confirm]
The Maplets[Examples][Confirm] 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:
?Maplets[Examples][Confirm]
To view the source code, enter:
print( Maplets[Examples][Confirm] );
See Also
Maplets[Examples], Maplets[Examples][Confirm], Maplets[Elements][ConfirmDialog]
Return to Index for Example Worksheets
Download Help Document