Navigation

Operators and Keywords

Function List:

C++ API

: [fname, fpath, fltidx] = uigetfile ()
: […] = uigetfile (flt)
: […] = uigetfile (flt, dialog_name)
: […] = uigetfile (flt, dialog_name, default_file)
: […] = uigetfile (…, "Position", [px py])
: […] = uigetfile (…, "MultiSelect", mode)

Open a GUI dialog for selecting a file and return the filename fname, the path to this file fpath, and the filter index fltidx.

flt contains a (list of) file filter string(s) in one of the following formats:

"/path/to/filename.ext"

If a filename is given then the file extension is extracted and used as filter. In addition, the path is selected as current path and the filename is selected as default file. Example: uigetfile ("myfun.m")

A single file extension "*.ext"

Example: uigetfile ("*.ext")

A 2-column cell array

containing a file extension in the first column and a brief description in the second column. Example: uigetfile ({"*.ext", "My Description";"*.xyz", "XYZ-Format"})

The filter string can also contain a semicolon separated list of filter extensions. Example: uigetfile ({"*.gif;*.png;*.jpg", "Supported Picture Formats"})

A directory name or path name

If the folder name of path name contains a trailing file separator, the contents of that folder will be displayed. If no trailing file separator is present the parent directory is listed. The substring to the right of the rightmost file separator (if any) will be interpreted as a file or directory name and if that file or directory exists it will be highlighted. If the path name or directory name is wholly or partly nonexistent, the current working directory will be displayed. No filter will be active.

dialog_name can be used to customize the dialog title.

If default_file is given then it will be selected in the GUI dialog. If, in addition, a path is given it is also used as current path.

The screen position of the GUI dialog can be set using the "Position" key and a 2-element vector containing the pixel coordinates. Two or more files can be selected when setting the "MultiSelect" key to "on". In that case fname is a cell array containing the files.

See also: uiputfile, uigetdir.

Demonstration 1

The following code

 uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'});

gives an example of how 'uigetfile' is used.

Package: octave