Interactively select a file for writing
Syntax
uiputfile
uiputfile('InitFile
')
uiputfile('InitFile
','DialogTitle
')
uiputfile('InitFile
','DialogTitle
',x,y)
[fname,pname] = uiputfile(...)
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.
uiputfile('InitFile
')
displays a dialog box that contains a list of files in the current directory determined by InitFile
. InitFile
is a full filename or includes the *
wildcard. For example, specifying '
*.m'
(the default) causes the dialog box list to show only MATLAB M-files. The Macintosh ignores the first argument.
uiputfile('InitFile
','DialogTitle
')
displays a dialog box that has the title DialogTitle
. On the Macintosh, the second argument is the label for the filename prompt. See the example below.
uiputfile('InitFile
','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 may not work on all platforms. On the Macintosh, the dialog box cannot overlap the menu bar.
[fname,pname] = uiputfile(...)
returns the name and path of the file selected in the dialog box. If you press the Cancel button or an error occurs, fname
and pname
are set 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'
(the exact appearance of the dialog box depends on your windowing system) with the filename animinit.m
. On the Macintosh, the second argument specifies the filename prompt.
[newfile,newpath] = uiputfile('animinit.m
','Save file name');
See Also
uigetfile
[ Previous | Help Desk | Next ]