open

open(): Integer updating;

The open method of the CMDFileOpen class initiates the common File Open dialog 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 position of the common File Open dialog cannot be determined. The values of the variable options for the class should be set before the open method is used.

If you want the user to be prompted to create the file each time a folder is navigated to from within the File Open dialog when the file does not exist, specify cmdFileOpen.createPrompt := true; before you call the CMDFileOpen class open method. (By default, a user who attempts to open a file that does not exist is advised that the file was not found, and to check the file name before trying again.)

The following example shows the use of the open method to open a common File Open dialog.

vars
    fopen : CMDFileOpen;
begin
    create fopen;
    fopen.initDir := app.dbPath;        // set the initial directory
    if fopen.open = 0 then              // not cancelled and no error
        self.name := fopen.fileTitle;   // use the returned value
    endif;
epilog
    delete fopen;                       // tidy
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.