A program is made up of a sequence of clauses and directives. The clauses of a predicate don't have to be immediately consecutive, but remember that their relative order may be important (see ref-sem).
To input a program from a file file, issue a query of the form:
| ?- consult(file).
This instructs the interpreter to read in (consult) the program. Note that it may be necessary to enclose the filename file in single quotes to make it a legal Prolog atom; e.g.:
| ?- consult('myfile.pl'). | ?- consult('/usr/prolog/somefile').
The specified file is then read in. Clauses in the file are stored so that they can later be interpreted, while any directives are obeyed as they are encountered. When the end of the file is found, the system displays on the standard error stream the time spent. This indicates the completion of the query.
Predicates that expect the name of a Prolog source file, or more generally a file specification, use the facilities described in ref-fdi to resolve the file name. File extensions are optional. There is also support for libraries.
This query can also take any list of filenames, such as:
| ?- consult([myprog,extras,tests]).
In this case all three files would be consulted. The clauses for all the predicates in the consulted files will replace any existing clauses for those predicates, i.e. any such previously existing clauses in the database will be deleted.