(deftemplate startup-rule
(multislot output)
(slot state))
(defrule end-state
=>
(open "output.dat" theFile "r")
(bind ?data (readline theFile))
(while (neq ?data EOF)
(bind ?data (?data readline theFile)))
(assert (startup-rule (output ?data)(state final)))
(close theFile) )
在这个默认情况下,我试图将从文件中读取的所有行绑定到?data变量中,然后将其声明为deftemplate启动规则,但这似乎不起作用。
答案 0 :(得分:0)
(defrule end-state
=>
(open "output.dat" theFile "r")
(bind ?str "")
(bind ?data (readline theFile))
(while (neq ?data EOF)
(bind ?str (str-cat ?str ?data))
(bind ?data (readline theFile)))
(assert (startup-rule (output ?str) (state final)))
(close theFile))