Next: , Up: GUI Development   [Contents][Index]


35.1 I/O Dialogs

Simple dialog menus are available for choosing directories or files. They return a string variable which can then be used with any command requiring a file name.

Function File: dirname = uigetdir ()
Function File: dirname = uigetdir (init_path)
Function File: dirname = uigetdir (init_path, dialog_name)

Open a GUI dialog for selecting a directory.

If init_path is not given the current working directory is used.

dialog_name may be used to customize the dialog title.

See also: uigetfile, uiputfile.

Function File: [fname, fpath, fltidx] = uigetfile ()
Function File: […] = uigetfile (flt)
Function File: […] = uigetfile (flt, dialog_name)
Function File: […] = uigetfile (flt, dialog_name, default_file)
Function File: […] = uigetfile (…, "Position", [px py])
Function File: […] = 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"})

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.

Function File: [fname, fpath, fltidx] = uiputfile ()
Function File: [fname, fpath, fltidx] = uiputfile (flt)
Function File: [fname, fpath, fltidx] = uiputfile (flt, dialog_name)
Function File: [fname, fpath, fltidx] = uiputfile (flt, dialog_name, default_file)

Open a GUI dialog for selecting a file.

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

"/path/to/filename.ext"

If a filename is given 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: uiputfile ("myfun.m")

"*.ext"

A single file extension. Example: uiputfile ("*.ext")

{"*.ext", "My Description"}

A 2-column cell array containing the file extension in the 1st column and a brief description in the 2nd column. Example: uiputfile ({"*.ext","My Description";"*.xyz", "XYZ-Format"})

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

dialog_name can be used to customize the dialog title. If default_file is given it is preselected in the GUI dialog. If, in addition, a path is given it is also used as current path.

See also: uigetfile, uigetdir.


Next: , Up: GUI Development   [Contents][Index]