Programming in XPCE/Prolog: Section 11.1

## 11.1 Library ``find_file''

The library `library(find_file)` defines the class finder, representing a modal dialog window for entering a filename. This class defines the method `finder`<-`file':

finder <-file: Exists:[bool], Ext:[name|chain], Dir:[directory], Def:[file]
  name Ask the user for a file. If Exists is @on, only existing files can be returned. Ext is either an atom denoting a single extension or a chain of allowed extensions. Extensions can be specified with or without the leading dot. I.e. both `pl` and `'.pl'` are valid specifications of files ending in `'.pl'`. Dir is the directory to start from. When omitted, this is the last directory visited by this instance of finder or the current working directory. Def is the default file-name returned. When omitted there is no default.

  Below is the typical declaration and usage. In this example we ask for an existing Prolog file.

      :- pce_autoload(finder, library(find_file)).
      :- pce_global(@finder, new(finder)).

              ...,
              get(@finder, file, @on, pl, PlFile),
              ...,

The Windows version of XPCE implements the method `display`<-`win_file_name', using the Win32 API standard functions GetOpenFileName() or GetSaveFileName() to obtain a file-name for saving or loading. If this method is defined, `finder`<-`file' uses it, showing the users familiar dialog.

Names for the extensions (as `Prolog file' rather than '*.pl') can be defined by extending the multifile predicate pce_finder:file_type/2. See the library source for the standard definition.