Application Center - Maplesoft

App Preview:

Classroom Tips and Techniques: Task Templates in Maple

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application



Classroom Tips and Techniques: Task Templates in Maple 

Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow

© Maplesoft, a division of Waterloo Maple Inc., 2006



The Tools menu in Maple 10 provides three categories of tools: the Assistants, Tutors, and Tasks (that is, Task Templates).  A Task Template provides a mathematical functionality as one or more Maple commands, or even as a set of embedded components.  The Task Templates extend Maple's point-and-click repertoire beyond what is provided by the palettes and context (pop-up) menus.  Moreover, the list of more than 200 built-in Task Templates can be extended by the user. 


In this column we detail the process of writing and saving a new Task Template. 



Writing a Task Template 


Cursory examination of any of the built-in Task Templates reveals that it is possible to write an elaborate wrapper for the essential functionality being provided.  Our discussion will show how to write minimalist templates that the reader can embellish. 


The first step in the writing process consists in entering the template into a blank worksheet or document, one complete template to a single file.  For example, the task might be to find the midpoint of a line segment given two points determining the segment.  One implementation might be as follows: 



[3, -1] 



[5, 7] 



[4, 3] 


Save the worksheet or document in which this template has been created.  If at a later time the template is to be edited or modified, the changes will have to be made here. 


The second step consists in saving the template to an appropriate file.  This is done with the Save as Task option in the Help Database section of the Tools menu.  See Figure 1 for details. 




Figure 1   Saving a Task Template 


The Save Task dialog box that appears upon selection of the Save as Task option is shown in Figure 2. 



Figure 2  The initial appearance of the Save Task dialog box 


In the Select Writable Database section, the first blank field near the top of the Save Task dialog box, enter the name of the file in which the template is to be stored.  The default name belongs to the file of built-in Task Templates.  Edit this name to something like 


C:\Program Files\Maple 10/lib/MyTasks.hdb 


This file will sit in the lib folder of the Maple 10 installation under Program Files in the typical Windows operating system.  This new file can contain multiple tasks, but each task must be created and saved from its own separate worksheet or document. 


Once this new file has been created, it will appear in the drop-down list provided in the Select Writable Database section.  This makes it easier to continue adding new Task Templates to the same file. 


In the Topic: Task/ field, enter a succinct name for the task; do not use spaces.  (LineSegment-Midpoint would be a viable name, although just Midpoint might work just as well.)  This name serves three purposes: 


  • It is the name that Maple's help system will recognize and find as part of a search.  

  • It is also the name that will appear in the drop-down list for Tasks after this task has been selected.  

  • Finally, this is the name you must use if you wish to delete this task from your database file.  (At the present time, there is no editor for Task Templates.  To modify an existing template, it must be deleted, and reinstalled.) Therefore, this name should be recorded somewhere, along with an appropriate description of what the task does.


The final entry is for what is to appear in the Table of Contents obtained with the ToolsTasksBrowse menu item.  Note that the built-in Table of Contents contains collapsed sections and subsections.  These are created by what is typed in the Table of Contents: Task/ field of the dialog box in Figure 2. 


Suppose we want our task to appear in the Algebra section under a sub-heading "Lines."  We would enter 


Algebra/Lines/Midpoint of a Line Segment 


In the Table of Contents, under Algebra, there would now be a subsection "Lines" and inside this subsection our task would have the name "Midpoint of a Line Segment." 


Complete the save operation by pressing the Save button on the bottom of the Save Task dialog box. 



Deleting a Task Template 


As we pointed out earlier, there is at present no editor for Task Templates.  Therefore, to modify or edit a Task Template, it must be deleted, and reinstalled after it is edited in its original worksheet. 


To remove a Task Template, select the Remove Topic option in ToolsHelp Database.  See Figure 3. 



Figure 3   Remove From Database dialog box 


In the Indexing Information/Topic field enter 




where the succinct space-free name used in the second line in the Save Task dialog box is appended to "Task/". 


In the Select Writable Database drop-down box, select the name of the hdb file where the task to be deleted was saved.  Then press the Remove button. 



Preventing Name Clashes 


In the event that a Task Template uses a variable to which an assignment has already been made in the underlying worksheet/document, there will be a name clash.  For example, the Task Template "Solve an Equation Symbolically," found under the Algebra heading in the Table of Contents for tasks, uses the variables x and y.  Suppose that an assignment has already been made to the variable y, say 


> y := 5



and then this Task Template is called.  A warning dialog such as seen in Figure 4 will appear. 



Figure 4   Dialog box for Task Variables 


If this dialog is ignored, the result of the ensuing calculation will be as follows. 



5 = exp(x)+3 




Notice that the variable y in the Task Template inherits the assigned value.  The Task Variables dialog box not only warns of the name clash, but also provides for renaming the problematic variable in the Task Template.  In this example, the name z could be entered as the New Name for the variable y.  Inserting the Task Template after this change leads to the following version of the calculation. 



z = exp(x)+3 




To teach a Task Template to scan for variable clashes and thereby to open the Task Variables dialog box, the process for creating the template must be modified.  In essence, each variable in the template must appear with leading and trailing double underscores.  Thus, the variable y would have to appear as __y__, where the space between the repeated underscores disappears under the typesetting rules. 


However, as in all of life, the devil is in the details.  It is easy enough to type the double underscore when working in text mode (1D math) but it is a little trickier to do this in math mode (2D math).  In math mode, the keys that normally enter an underscore put the cursor into subscript mode, so an escape sequence must be used to actually type an underscore.  Thus, in math mode, the key sequence for a single underscore must start with the backslash (\) character. 


My aging eyes and stiffening fingers find doing this four times for every variable really tedious.  Moreover, Maple does not yet allow Find/Replace for characters typed in math mode, so the double underscores for variable must be inserted by hand. 


Here are several options for making the double underscore easier to install. 


  • Write the Task Template in text mode (1D math).  Use Find/Replace to convert variables to their double-underscore version.  Then convert each 1D command to 2D input with either the pop-up context menu or with the Format/Convert pull-down menu.  (In Windows, the keyboard equivalent is ALT RVM after selecting the 1D math to be converted.)


  • Alternatively, write the Task Template in math mode (2D) but without double underscores.  When done, create (in math mode) one double-underscored copy of each relevant variable, then copy and paste this where needed.


  • Of course, the Task Template could be written in test mode using just 1D math input, but even a casual inspection of the built-in Task Templates reveals that they were written in 2D math.  For the purist who wants consistency, the urge to write in 2D math will eventually lead to the path just sketched.



Placeholder Fields 


The built-in Task Templates generally have fields (highlighted in color) called Task Elements.  To see these Task Element fields in an inserted Task Template, select Task Elements from the View menu. 


The cyan-colored placeholder fields are of great utility.  Example 1 illustrates the functionality of such a placeholder field. 


Example 1 


Suppose we want to compute the dot product of the two vectors 


> Vector[column](%id = 146741988)

Vector[column](%id = 150943180) 




> Vector[column](%id = 146887348)

Vector[column](%id = 146204844) 


Using the ToolsTasks menu, browse to the Vector Calculus section of the Table of Contents.  Insertion (minimal) of the "Dot Product of Two Vectors" template leads to 


> with(VectorCalculus, `.`); -1

> Typesetting:-delayDotProduct(`<,>`(2, -3, 0), `<,>`(-1, -2, 5))



The two Task Element fields are highlighted.  If the cursor is located before this insertion, then with  




the toggle for the tab key, set to "advance to next field", tab until the start of the first Task Element is selected.  (See Figure 5.) 



Figure 5   Tabbing to Task Element 


To apply this template to the two vectors of Example 1, press the Ctrl and L keys (Command + L on a Macintosh) to launch the Equation Label dialog box.  Into this box enter the number 9, the equation label of the first vector in Example 1.  Closing the dialog box replaces the three numbers in the template vector with the equation label of the first vector in Example 1. 


Press the tab key again so the second Task Element is selected.  Again use the Equation Label dialog to enter the equation label of the second vector.  When the Equation Label dialog is closed, the second vector in the Task Template is replaced by the equation label of the second vector of Example 1.  Finally, pressing the Enter key will execute the desired dot product. 



Setting Placeholder Fields 


A placeholder field is set in a Task Template when it is authored.  Select the item that is to become a placeholder.  Using the FormatTask Authoring menu, simply select the option Mark As Placeholder.  (From the keyboard, use ALT RTP.) 




Legal Notice: The copyright for this application is owned by Maplesoft. The application is intended to demonstrate the use of Maple to solve a particular problem. It has been made available for product evaluation purposes only and may not be used in any other context without the express permission of Maplesoft.