0
votes

From the swi prolog shell I can load prolog files using load_files(filename).

But if I call load_files from a prolog file does not work.

I'm new at prolog.

I tried to end the file with .pl or put the name of the file between "" or ''.

The following do not work:

Contents of file1.pl: dog(a). dog(b).

Contents of file2.pl: dog(c). load_files(file1).

If now from the prolog shell I do load_files(file2) it doesn't load the dogs a and b.

If I do this, the following error is shown: ?- load_files(file2). true.

?- dog(M). ERROR: toplevel: Undefined procedure: dog/1 (DWIM could not correct goal)

1

1 Answers

0
votes

You should use the include() predicate to load the contents of a file. So in file2.pl, you would have:

dog(c).
:- include("file1.pl").

The contents of file2.pl will be loaded right after dog(c).