define a file chooser dialog
equation(s) of the form option=value where option is one of approvecaption, closeonapprove, directory, filefilter, filename, fileselectionmode, filterdescription, height, onapprove, oncancel, reference, resizable, title, value, or width; specify options for the FileDialog element
name or string; reference to the element
The FileDialog dialog element defines a file chooser dialog.
Maplets dialog elements have a predefined layout. For a dialog, an author cannot specify elements. This is different from the Window element, which can contain other elements, for example, buttons and layout elements.
The FileDialog element features can be modified by using options. To simplify specifying options in the Maplets package, certain options and contents can be set without using an equation. The following table lists elements, symbols, and types (in the left column) and the corresponding option or content (in the right column) to which inputs of this type are, by default, assigned.
Elements, Symbols, or Types
Assumed Option or Content
string or symbol
A FileDialog element can contain Action or command elements to specify the onapprove and oncancel options.
A FileDialog element can be contained in a Maplet element.
The following table describes the control and use of the FileDialog element options.
An x in the I column indicates that the option can be initialized, that is, specified in the calling sequence (element definition).
An x in the R column indicates that the option is required in the calling sequence.
An x in the G column indicates that the option can be read, that is, retrieved by using the Get tool.
An x in the S column indicates that the option can be written, that is, set by using the SetOption element or the Set tool.
The opts argument can contain one or more of the following equations that set Maplet application options.
approvecaption = string or symbol
The text that appears on the approval button. By default, the text is Open.
closeonapprove = true or false
Indicates whether the file dialog should close when the approval button is clicked. Setting this to false leaves the dialog open after the approval button is clicked, and it must be manually closed after validation is performed from within the opapprove action. The default is true.
directory = string
The current directory for the file dialog.
filefilter = string
Searches for the file extension specified. The default is all files, which is equivalent to a filefilter of "*". To specify only files with a non-empty extension, use "*.*". To specify more than one file extension, separate by a comma, as in "*.gif,*.jpg".
filename = string
The name of the currently selected file for the file dialog.
fileselectionmode = filesonly, directoriesonly, filesanddirectories
The type of files to allow for selection. By default this value is filesonly, which means that only files can be selected.
filterdescription = string
This is a description of the filter provided by the option filefilter. The default description is "All Files".
height = posint
The window height in pixels.
onapprove = Action or command element, or reference to an Action element (name or string)
The action that occurs when the approval button is clicked if a file (not a directory) is selected. By default, the action shuts down the dialog.
oncancel = Action or command element, or reference to an Action element (name or string)
The action that occurs when the Cancel button is clicked. By default, the action shuts down the dialog.
reference = name or string
A reference for the FileDialog element.
If the reference is specified by both an index, for example, FileDialog[refID], and a reference in the calling sequence, the index reference takes precedence.
resizable = true or false
Whether the user can resize the window. By default, false.
title = string or symbol
The text that appears in the title bar of the file dialog. The default title is Select File.
* value = string
The string that represents the file that is currently selected, for example, "C:\\myfile.mpl". It is generally advisable to use the directory and filename options for setting an initial directory/file, and using value for output.
width = posint
The window width in pixels.
A Maplet application that has one file dialog, which returns the file selected in a list or NULL:
maplet ≔ Maplet⁡FileDialog'FD1'⁡'filefilter'=mpl,'filterdescription'=Maple Source Files,'onapprove'=Shutdown⁡'FD1','oncancel'=Shutdown⁡:
Overview of Maplet Applications
Download Help Document