1. Computing
Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

PromptForFileName

unit
Dialogs
category
Dialog and Message routines

declaration
function PromptForFileName(var AFileName: string; const AFilter: string = ''; const ADefaultExt: string = ''; const ATitle: string = ''; const AInitialDir: string = ''; SaveDialog: Boolean = False): Boolean;

description
Displays an open or save dialog, enabling the user to select or specify a file name. PromptForFileName returns true if the user selected a file name, false if the user exited by clicking the cancel button.
The AFilename value supplied by the call is used to initialize the file name in the dialog. On exit, AFileName contains the name specified in the dialog.
AFilter determines the file masks (filters) available in the dialog. If set to an empty string, the dialog uses the string 'All files (*.*)|*.*', which causes the dialog to display all files in the current directory.
ADefaultExt specifies a file extension that is appended automatically to the specified file name.
ATitle specifies the title for the dialog. If ATitle is set to an empty string, the dialog uses ‘Open’ or ‘Save As’, depending on the value of the SaveDialog parameter.
AInitialDir specifies the directory displayed in the dialog when it opens.
SaveDialog specifies whether the file selection should be a Save As dialog (true) or an Open dialog (false).

example
var 
  AFileName: string
	
//displays the save as dialog for an application defined data with extension MAF...

if PromptForFileName(AFileName, 'My App files(*.maf)|*.maf', '',
                     'Save the data as...'; ExtractFileDir(Application.ExeName),
                     True) then
...

in real code
Articles
Various Delphi Programming technical articles.

see also
SelectDirectory,


 Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

 Got some code to share? Got a question? Need some help?

©2013 About.com. All rights reserved.