【问题标题】:CLIPS How can I bind data read from a file to one variableCLIPS 如何将从文件读取的数据绑定到一个变量
【发布时间】:2018-05-22 12:30:36
【问题描述】:
(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) )

在这个 defrule 中,我试图将从文件中读取的所有行绑定到 ?data 变量中,然后在 deftemplate 启动规则中断言,但这似乎不起作用。

【问题讨论】:

    标签: clips


    【解决方案1】:
    (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))
    

    【讨论】:

      猜你喜欢
      • 2018-12-21
      • 1970-01-01
      • 1970-01-01
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多