1

I have a simple prolog program:

write_manual:-
   write('------------------------------'),
   write('USAGE MANUAL'),
   write('find_course. - List all the available courses'),
   write('------------------------------').
   % execute this and output this right away when I open the program in the console

Does anyone know to achieve this? I'd like to print a simple help manual before the program starts. Currently, the swi prolog console (on windows 10) shows the ?- prompt and requires me to manually call the predicate. I'm using SWI-Prolog (threaded, 64 bits, version 8.0.0).

danieln
  • 473
  • 1
  • 5
  • 20
  • Does this answer your question? [How to run SWI-Prolog from the command line?](https://stackoverflow.com/questions/25467090/how-to-run-swi-prolog-from-the-command-line) – Guy Coder Feb 13 '20 at 12:46
  • @GuyCoder havent been able to get `initialization main.` to work (nothing is output to the swi console). I'm running the program using the `file > consult` option of the swi prolog console (not shell). – danieln Feb 13 '20 at 13:22
  • @GuyCoder see the edits. Yes, I'm running on windows 10 – danieln Feb 14 '20 at 09:37

1 Answers1

2

This is a comment posted in a question because it doesn't format correctly in a comment.

Running on Windows 10 with SWI-Prolog (threaded, 64 bits, version 8.1.21)

:- initialization main.

main :-
    write_manual.

write_manual :-
    format('------------------------------~n',[]),
    format('USAGE MANUAL~n',[]),
    format('find_course. - List all the available courses~n',[]),
    format('------------------------------~n',[]).

Start SWI-Prolog

?- consult("C:/Prolog/SO_question_160.pl").
------------------------------
USAGE MANUAL
find_course. - List all the available courses
------------------------------
true.

?- 

Note: This was not setup to start from a Windows command line script because the title of the question reads I consult a file.

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
  • That is what I don't get about SO, I get more points from comments like this where I don't want the points, than I do from great answers like [this](https://stackoverflow.com/a/53412988/1243762) where it would nice to get more up-votes. – Guy Coder Feb 13 '20 at 13:53
  • @false 12 = 4 hours, 1 = 30 seconds. Units of measure. – Guy Coder Feb 13 '20 at 22:44
  • @GuyCoder the swi prolog console on windows 10 has an option to consult/run program from file `menu > file > consult`. (I edited the title). Also, I'm relatively new to ai and prolog so I'm still getting acquainted to the usage and paradigms as well – danieln Feb 14 '20 at 09:33