如果您使用 load 命令加载此内容,那么您将命令(例如 clear)与 CLIPS 结构(例如 deftemplate 和 defrule)混合。为了解决这个问题,首先创建一个文件,比如 book.clp ,只包含结构:
(deftemplate book
(multislot surname)(slot name)(multislot title)
)
(deffacts initial
(book (surname J.P.)(name Dubreuil)(title History of francmasons))
(book (surname T.)(name Eker)(title Secrets of millionaire mind)))
(defrule find_title
?book<-(book(name Eker))
=>
(printout t ?book crlf)
)
然后您可以使用 load 命令加载文件并运行它:
CLIPS> (clear)
CLIPS> (load book.clp)
%$*
TRUE
CLIPS> (reset)
CLIPS> (agenda)
0 find_title: f-2
For a total of 1 activation.
CLIPS> (facts)
f-0 (initial-fact)
f-1 (book (surname J.P.) (name Dubreuil) (title History of francmasons))
f-2 (book (surname T.) (name Eker) (title Secrets of millionaire mind))
For a total of 3 facts.
CLIPS> (run)
<Fact-2>
CLIPS>