Pascal Scripting: GetSaveFileName

Prototype

function GetSaveFileName(const Prompt: String; var FileName: String; const InitialDirectory, Filter, DefaultExtension: String): Boolean;

Description

Displays a dialog box that enables the user to select a new file. Returns True if the user selected a file, False if the user cancelled the dialog box. The name of the selected file is returned in the FileName string.

An exception will be raised if an error occurs.

Remarks

An example Filter: 'Text files (*.txt)|*.txt|All files (*.*)|*.*'

Example:
var
  Filename: String;
begin
  // Set the initial filename
  Filename := '';
  if GetSaveFileName('', Filename, '',
     'Text Documents (*.txt)|*.txt|All Files|*.*', 'txt') then
  begin
    // Successful; user clicked OK
    // Filename contains the selected filename
  end;
end;