Prolog:我参考文件后立即打印到控制台

问题描述 投票:-1回答:1

我有一个简单的序言程序:

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

有人知道要实现这一目标吗?我想在程序启动之前打印一份简单的帮助手册。当前,swi prolog控制台显示-?提示并要求我手动调用谓词。我正在使用SWI-Prolog (threaded, 64 bits, version 8.0.0)

prolog swi-prolog
1个回答
0
投票

这是在问题中发布的评论,因为其格式不正确。

[在Windows 10上使用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',[]).

开始SWI-Prolog

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

?- 

注意:这不是设置为从Windows命令行脚本开始,因为问题的标题为I consult a file

© www.soinside.com 2019 - 2024. All rights reserved.