【问题标题】:Prolog: Print to swi prolog console immediately I consult a fileProlog:立即打印到 swi prolog 控制台我查阅文件
【发布时间】:2020-02-13 12:24:11
【问题描述】:

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

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 控制台(在 Windows 10 上)显示 ?- 提示并要求我 手动调用谓词。我正在使用 SWI-Prolog (threaded, 64 bits, version 8.0.0)

【问题讨论】:

  • 这能回答你的问题吗? How to run SWI-Prolog from the command line?
  • @GuyCoder 无法让initialization main. 工作(没有任何内容输出到 swi 控制台)。我正在使用 swi prolog 控制台(不是 shell)的 file > consult 选项运行程序。
  • @GuyCoder 查看编辑。是的,我在 Windows 10 上运行

标签: prolog


【解决方案1】:

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

使用SWI-Prolog (threaded, 64 bits, version 8.1.21)在 Windows 10 上运行

:- 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

【讨论】:

  • 这就是我不明白的地方,我从这样的 cmets 获得的分数比我不想要的分数多,而不是像 this 这样的好答案获得更多支持。
  • @false 12 = 4 小时,1 = 30 秒。计量单位。
  • @GuyCoder Windows 10 上的 swi prolog 控制台可以选择从文件 menu > file > consult 咨询/运行程序。 (我编辑了标题)。另外,我对 ai 和 prolog 比较陌生,所以我仍然熟悉用法和范例
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多