
(****************************************
*                                       *
*     MODULA-2 Multi-Pass Compiler      *
*     ****************************      *
*                                       *
*     Implementation for Lilith         *
*     adapted for SMAKY 8               *
*                                       *
*                                       *
*     MCLookup:                         *
*                                       *
*     Lookup on files according to      *
*     different searching strategies    *
*                                       *
*     Version C19 of 23.07.82           *
*                                       *
*     Institut fuer Informatik          *
*     ETH-Zuerich                       *
*     CH-8092 Zuerich                   *
*                                       *
****************************************)

DEFINITION MODULE MCLookup;        (* LG , PF 13.07.83 *)

  FROM M2Files  IMPORT File;

  EXPORT QUALIFIED LookupFile,CreateFile, SetLibraries;

  PROCEDURE LookupFile(VAR prompt: ARRAY OF CHAR;
                       VAR name: ARRAY OF CHAR;
                       VAR defext: ARRAY OF CHAR;
                       VAR file: File;
                       query, acceptdefault, acceptoptions: BOOLEAN;
                       VAR acceptedfilename: ARRAY OF CHAR;
                       VAR goodfile: BOOLEAN; VAR nofile1: BOOLEAN);

    (* for implementation the modules:         *)
    (* Options and CompFile are imported       *)

    (* prompt        : string is displayed on terminal *)
    (* name          : for construction of a default file name *)
    (*                 name of the module to be opened, i.e. for which
                       a file name.ext, or LIB.name.ext must be found *)
    (* defext        : default extension of searched file *)
    (* file          : opened file (read-only mode)  *)
    (* query         : explicit asking for file name *)
    (* acceptdefault : accept a default file name *)
    (* acceptoptions : accept options appended to file name *)
    (*                 options are not evaluated *)
    (* acceptedfilename: final file name  *)
    (* goodfile      : lookup was successful *)
    (* nofile1       : operator said: omit this file *)


PROCEDURE CreateFile (VAR prompt: ARRAY OF CHAR;
                      VAR name  : ARRAY OF CHAR;
                      VAR newext: ARRAY OF CHAR;
                      VAR file  : File;
                      query, acceptdefault, acceptoptions:BOOLEAN;
                      VAR acceptedfilename: ARRAY OF CHAR;
                      VAR goodfile: BOOLEAN; VAR nofile1: BOOLEAN);

     (* nearly the same as LookupFile. to open an output file with query*)
     (* doesnt try different libraries to create the file *)
     (* the extension is always changed to newext if default is TRUE *)

PROCEDURE SetLibraries (VAR defaultlibstring: ARRAY OF CHAR;
                        query, changedefault: BOOLEAN);
     (* set the libraries to be used in the searching strategy, and/or ask
        the user:
        defaultlibstring: 1 or more library names, separated by comma.
                          or a full filename, from which the library name
                          will be extracted (e.g. source file name).
        query           : if the user should be asked for a libstring.
        changedefault   : TRUE  install 'defaultlibstring'.
                          FALSE = ignore it, use the previous libstring  *)

END MCLookup.

