danieln
danieln

Reputation: 513

Prolog: Print to swi prolog console immediately I consult a file

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).

Upvotes: 1

Views: 1393

Answers (1)

Guy Coder
Guy Coder

Reputation: 24976

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.

Upvotes: 2

Related Questions