open

open(): Integer updating;

The open method of the CMDFileSave class initiates the common File Save dialog for the CMDFileSave class and returns a value indicating the success of the user actions, as listed in the following table.

Value Description
0 User clicked the OK button. Values of the selections made are returned.
1 User clicked the Cancel button.
Other Windows error number indicating a fault associated with the execution of the dialog.

The following example, which uses the CMDFileSave class:

  1. Displays a common File Save dialog.

  2. Obtains the file selected by the user.

  3. Writes details of products to the file.

vars
    file  : File;
    myDlg : CMDFileSave;
    prod  : Product;
begin
    create myDlg;
    if myDlg.open = 0 then                      // user clicked OK
        create file;
        file.fileName    := myDlg.fileName;     // get selected name
        file.mode        := File.Mode_Append;
        file.allowCreate := true;               // create if not there
        file.open;                              // not mandatory
        foreach prod in company.allProducts do
            file.writeLine(prod.code & ":" & prod.description);
        endforeach;
        file.close;
        delete file;
    endif;
epilog
    delete myDlg;
end;

Any values that are returned are retained if further calls are made on the class instance. The object should be deleted when it is no longer required.

An exception is raised if this method is invoked from a server method.

The position of the displayed File Save dialog cannot be determined. The values of the variable options for the class should be set before the open method is used.