MATLAB Function Reference    
uiputfile

Standard dialog box for saving files

Syntax

Description

uiputfile displays a dialog box used to select a file for writing. The dialog box lists the files and directories in the current directory using the default

uiputfile('FilterSpec') displays a dialog box that contains a list of files in the current directory determined by FilterSpec.

FilterSpec determines what files are displayed initialy in the dialog box. For example '*.m' lists all MATLAB M-files.

If FilterSpec is a cell array, the first column is used as the list of extensions, and the second column is used as the list of descriptions.

If FilterSpec is not specified, uiputfile uses the default list of file types (i.e., all MATLAB files).

FilterSpec can also be a default file name, in which case, the file's extension is used as the default filter.

uiputfile('FilterSpec','DialogTitle') displays a dialog box that has the title DialogTitle. To use the default file types and specify a dialog title, use:

uiputfile('FilterSpec','DialogTitle',x,y) positions the dialog box at screen position [x,y], where x and y are the distance in pixel units from the left and top edges of the screen. Note that positioning works only on UNIX platforms.

[FileName,PathName] = uiputfile(...) returns the name and path of the file selected in the dialog box. If the user clicks the Cancel button, closes the dialog window, or if an error occurs, FileName and PathName are set to 0.

[FileName,PathName,FilterIndex] = uiputfile(...) returns the index of the filter selected in the dialog box. The indexing starts at 1. If the user clicks the Cancel button, closes the dialog window, or if an error occurs, FilterIndex is se to 0.

Remarks

If you select a file that already exists, a prompt asks whether you want to overwrite the file. If you choose to, the function successfully returns but does not delete the existing file (which is the responsibility of the calling routines). If you select Cancel in response to the prompt, the function returns control back to the dialog box so you can enter another filename.

Examples

This statement displays a dialog box titled 'Save file name' with the filename animinit.m.

This statement displays a dialog box titled 'Save Workspace As' with the filter specifier set to MAT-files.

You can specify a description of the file type in the FilterSpec argument:

When you use multiple extensions with no descriptions, you must separate each with a semicolon:

Associate multiple extensions with one description like this:

See Also

uigetfile


  uint8, uint16, uint32, uint64 uiresume, uiwait