How to run prolog queries from within the prolog file in swi-prolog?

Viewed 6878

If I have a prolog file defining the rules, and open it in a prolog terminal in windows, it loads the facts. However, then it shows the ?- prompt for me to manually type something. How can I add code to the file, so that it will actually evaluate those specific statements as if I typed them in?

something like this

dog.pl

dog(john).
dog(ben).

% execute this and output this right away when I open it in the console
dog(X).

Does anyone know how to do this?

Thanks

3 Answers
Related