Information Technology Reference
In-Depth Information
Appendix C
Getting Your Prolog Programs to Work
I assume that SWI-Prolog has been installed, and that the family.pl program works
for you just like in figure 3.2. (Otherwise, see appendix B.) This appendix considers
how to use some of the features of SWI-Prolog to get new Prolog programs that you
write to work as intended. (There are, of course, many ways of doing this, but what
follows are my recommendations.)
When you are using SWI-Prolog on your computer, keep two windows open and
work as follows:
1.
Start your text editor (see appendix A), and either type in or open the current ver-
sion of your own Prolog program. Save the file (with a name like something.pl ),
but keep this window open.
2.
Start Prolog and load the current version of your program (as described for
family.pl in appendix B). This will be your second window.
3.
Try some Prolog queries in the Prolog window.
4.
If the queries all work as expected, then you are done. You may want to save some
queries and their results for the record. Then quit Prolog and the text editor.
5.
If some queries do not work as expected, find out what went wrong, make some
changes in the text editor window, save the file, and then reload the program
into Prolog. Then go back to step 3.
Let us go through these steps to see what can go wrong.
C.1 Getting program files to load
One problem you may have is that you try to load a program file (using the square
brackets), but the file is not found:
?- [block].
ERROR: source_sink 'block' does not exist
 
 
Search WWH ::




Custom Search