Maplet Application Style Guide
This document provides recommendations for structuring Maplet application code. Structuring improves readability of the Maplet application code both by yourself and future Maplet application authors who must maintain or understand the Maplet application.
In writing Maplet applications, follow these guidelines:
1. Use one element definition per line. If the element definition is short, more than one definition can be used.
2. Indent each subsequent element or nested list.
3. Place closing parentheses, brackets of elements, or nested lists at the same level of indentation as the opening line.
4. Informational elements, such as Fonts and Image, can be defined anywhere. The Maplet application code, however, is easier to read if the information elements are defined first in the Maplet application.
5. Keep attributes separate from the content of an element.
6. Place unevaluation quotation marks around any symbols or names being used as option names or references. Otherwise, if any of the symbols or names are ever assigned, your Maplet application definition will break.
7. Within a procedure, use the use statement and not the with statement. If another user runs your code, the with command affects that user's environment, while use does not.
Correct Maplet Application Code Structure
The following illustrates correct Maplet application code structure.
use Maplets[Elements] in
maplet := Maplet(
'onstartup' = RunWindow( 'W1' ),
Font['F1']( 'family' = "helvetica",'size'=12 ),
Window['W1']( "Vector Norm",
TextBox( 'editable' = 'false', 'width' = 50, 'font' = 'F1',
"A vector norm is a function ||V|| that satisfies the conditions of a norm."
"Norm (Select from list or enter non-negative number): ",
ComboBox['CoB1']( ["infinity", "1", "Euclidean (2)", "Frobenius"] )
"Vector has real entries: ",
CheckBox['ChB1']( 'true' )
"Evaluate result: ",
CheckBox['ChB2']( 'true' )
Button['B1']( "OK", Shutdown(['CoB1', 'ChB1', 'ChB2']) ),
Button['B2']( "Cancel", Shutdown() )
Return to Index for Example Worksheets