PLOGHELP LIBRARY                         Jonathan Laventhol, 7 July 1983
                              Revised by Kathryn Seifert  September 1986

How to access library files and how to add your own libraries

    ?- library(<atom>).

Keywords: libraries, documentation access, autoload, showlib,


CONTENTS - (Use <ENTER> g to access sections)

 -- INTRODUCTION
 -- LOADING LIBRARY FILES
 -- EXAMINING LIBRARY FILES
 -- AUTOLOADING
 -- ADDING YOUR OWN LIBRARY DIRECTORY
 -- RELATED DOCUMENTATION


-- INTRODUCTION -------------------------------------------------------

There are a number of library directories in the Prolog system, and it
is possible to add your own.  This file describes how to get at the
programs in them, and how to add your own personal library files.


-- LOADING LIBRARY FILES ----------------------------------------------

PLOGHELP * LIBRARIES gives a list of the library files available in the
Prolog system.  In order to load one of these library files, type:

    ?- library(<filename>).

The predicate 'library' reconsults a library file.  Note that with this
predicate, it is not necessary to include the '.pl' extension on the
filename:

    ?- library(date).

is the same as

    ?- library('date.pl').

If 'library' can't find the file, then the goal fails and a message is
printed.

    See PLOGHELP * RECONSULT


-- EXAMINING LIBRARY FILES --------------------------------------------

You can examine any library file with 'showlib' (see HELP * SHOWLIB). As
with 'library', the '.pl' extension is not needed at the end of the
filename.  However, if you have Prolog loaded and you wish to examine a
POP-11 library file, then you must specify the '.p' extension.

If you do not have Prolog loaded and you wish to examine a Prolog
library file, you can use 'plogshowlib' (see HELP * PLOGSHOWLIB).

PLOGHELP * LIBRARIES gives a summary of the Prolog library files.


-- AUTOLOADING --------------------------------------------------------

It is possible to make Prolog load library files automatically.  You can
alter the action taken when an undefined predicate is encountered, so
that the system looks in the library directories for a file with the
same name as the predicate and with filetype '.pl'; if it finds one it
will reconsult it.

Try:

    ?- library(unknown), unknown(_, autoload).
    yes

    ?- prolog_undefined_action(date(X), autoload).
    Attempting to autoload date
    X = [2, sep, 1986, 13, 13, 37]
    ? 
    yes

If the file can't be found then a mishap occurs:

    ?- kat.
    Attempting to autoload kat
    Can't find library file

    ;;; PROLOG ERROR - UNDEFINED PREDICATE
    ;;; INVOLVING: kat
    ;;; DOING:    undefined/0
    ;;; [execution aborted]

For more information see PLOGHELP * UNKNOWN, SHOWLIB * UNKNOWN.


-- ADDING YOUR OWN LIBRARY DIRECTORY ----------------------------------

There is a POP-11 list of directories which Prolog will recognise as
containing library files; that is, both "library" and "showlib" use
this list.  As there is no way yet of altering this list directly from
Prolog, you have to go via POP-11:

Assuming you want to add the directory kaths/ploglib to the library
list:

    ?- prolog_language(pop11).

    'kaths/ploglib'  :: prologliblist -> prologliblist;

    prolog

    Setprolog


-- RELATED DOCUMENTATION ----------------------------------------------

HELP * LIB
 Loading libraries in POP-11

HELP * POPAUTOLIST
 List of directories searched by POP-11 autoload mechanism

HELP * PROLOGLIBLIST
 POP-11 variable holding list of directories of Prolog library files

HELP * LIBRARIES
 Overview of POP-11 library facilities

HELP * SHOWLIB
 How to examine the contents of POP-11 and Prolog library files

PLOGHELP * LIBRARIES
 Overview of Prolog library programs

PLOGHELP * PLOGSHOWLIB
 To examine the contents of Prolog library files when Prolog not loaded

PLOGHELP * UNKNOWN
 Altering the action taken when undefined predicates encountered

--- C.all/plog/help/library
--- Copyright University of Sussex 1989. All rights reserved. ----------
