PromptForFileName function
Displays a file open or save dialog to select a file name for the operation.
Declaration
function PromptForFileName(var AFileName: string;
const AFilter: string='';
const ADefaultExt: string='';
const ATitle: string='';
const AInitialDir: string='';
AIsSaveDialog: Boolean=False) : BooleanArguments
AFileName | Updated to contain the file name selected in open or save dialog. |
AFilter | File masks used in the dialog. |
ADefaultExt | Default file extension for the file name selected in the dialog. |
ATitle | Title displayed on the dialog. |
AInitialDir | Initial directory displayed in the dialog. |
AIsSaveDialog | True to create a save dialog, False to create an open dialog. |
Function result
True if a file name was selected using the dialog.Description
PromptForFileName is a Boolean function used to display an Open or Save
dialog using the values passed as arguments to the routine. It creates a
TOpenDialog or a TSaveDialog instance for use in the
routine. The AIsSaveDialog argument determines which dialog class
is used in the routine.
Argument values are assigned to the corresponding properties in the dialog class. The Execute method in the dialog class is called to perform file selection or creation as needed, and its return value is used as the return value for the routine. The return value is True when the Execute method for the dialog class returns True.
AFilename contains the initially selected file name in the dialog,
and is updated with the value selected using the dialog. A default value is
not provided for the argument. If the dialog returns
True, the
FileName property in the dialog class is assigned to the AFileName argument.
AFilter contains file masks that can be selected in the dialog.
The default value is an empty string ('') and causes the all files mask
('*.*' or '*') to be used. See TFileDialog.Filter for more information about
the notation allowed in the argument.
ADefaultExt contains the file extension used for the file name
selected in the routine. The default value for the argument is an empty
string ('') and indicates that a default file extension is not used. See
TFileDialog.DefaultExt for more information about default extensions.
ATitle contains the caption displayed on the dialog. The default
value is an empty string ('') and allows the default value provided by the
dialog class to be used.
AInitialDir indicates the initial directory when the dialog is
displayed. The default value is an empty string ('') and causes the current
directory in the application to be used as the initial directory in the
dialog.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
