File Dialog - Maple Help

Maplets[Elements]

 FileDialog
 define a file chooser dialog

 Calling Sequence FileDialog(opts) FileDialog[refID](opts)

Parameters

 opts - 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 refID - name or string; reference to the element

Description

 • 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 refID reference option string or symbol title option

 • 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.

 Option I R G S approvecaption x x x closeonapprove x directory x x x filefilter x filename x x x fileselectionmode x x filterdescription x height x x x onapprove x oncancel x reference x resizable x x x title x x x value* x x x width x x x

 • 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.

Examples

A Maplet application that has one file dialog, which returns the file selected in a list or NULL:

 > $\mathrm{with}\left(\mathrm{Maplets}\left[\mathrm{Elements}\right]\right):$
 > $\mathrm{maplet}≔\mathrm{Maplet}\left(\mathrm{FileDialog}\left['\mathrm{FD1}'\right]\left('\mathrm{filefilter}'="mpl",'\mathrm{filterdescription}'="Maple Source Files",'\mathrm{onapprove}'=\mathrm{Shutdown}\left(\left['\mathrm{FD1}'\right]\right),'\mathrm{oncancel}'=\mathrm{Shutdown}\left(\right)\right)\right):$
 > $\mathrm{Maplets}\left[\mathrm{Display}\right]\left(\mathrm{maplet}\right)$