Keeping a record of what you have done:

You will sometimes want to keep a record of what you have been typing into the Prolog interpreter and the responses the system gives you. Knowing how to do this can be useful for at least two reasons. First, some coursework assignments require the submission of the output of your programs when run. Second, a copy of what your program does is a useful supplement to a program listing when your program doesn't work and you want advice.

The method used to collect many of the examples used in these notes was to use a "script file" to log everything that was typed. Before you start Prolog, type the command script <filename>.sct. As an example:

     pelleas% script sicstus.sct
     Script started, file is sicstus.sct
     pelleas%

You then invoke Prolog, load and edit programs and enter queries just as normal. After you halt Prolog, hold down the <CNTL> key and press D. (Unix displays this on the screen as "^D".) Unix will give you a very brief message that, in some versions of Unix, doesn't even remind you of the name of the script file.

     | ?- halt.
     pelleas% ^D
     Script done, file is sicstus.sct
     pelleas%


Printing script files from the DEC Alphas is best done by passing the file through a filter and thence on to a laser printer. For instance:

     pelleas% a2ps sicstus.sct | lpr -Plw-g10

Unfortunately, this produces a printed page with a control character "^M" displayed at the end of each line. On the Sun Unix systems, it is possible to remove these using the dos2unix filter. To use this, you need to filter your script file into another file and then print this second one in the same way. For example:

     pelleas% dos2unix sicstus.sct sicstus_copy.sct
     pelleas% a2ps sicstus_copy.sct | lpr -Plw-g10


© P.J.Hancox@bham.ac.uk