CFileDlg:Save


The Save method opens the Windows Save dialog to browse for a file name to use in saving a file. You can choose a file name from the folder or specify a new file name. After clicking[Save], the specified file name is returned. Since this dialog does not actually save the file, its main use is to either allow an existing file name to be selected or a file name to be entered that does not overwrite a file name that already exists in a target folder.

Syntax

sName, bSuccess = CFileDlg:Save()

sName, bSuccess = CFileDlg:Save( sDefaultFileName )

where

    ThesDefaultFileName argument is an optional file name to be used when the dialog opens.

    If[Save] is clicked, this method returns the file name in sName, and sets bSuccess=true.

    If the dialog is canceled, "", false is returned.

    ThebSuccess return value is optional.

  

Two values are returned: The first value is the full path name of the specified file and the second value bSuccess defines how the dialog was closed. If the dialog was canceled, false is returned as the second value. You do not have to specify the second argument in the script, but it it useful for determining that the user canceled the Save dialog.

Examples

The dialog shown above was created using the following script:

F = CFileDlg:new()

-- create a CFileDlg object, F

sName, bSuccess = F:Save( "Centroid Data" )

-- Specify a default file name "Centroid Data"

Assert(bSuccess)

-- exit the script if the dialog was canceled

Related Topics

CFileDlg

Open

GetFileNameSave