КЛИПЫ Как связать чтение данных из файла с одной переменной - PullRequest
0 голосов
/ 22 мая 2018
(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, однако, похоже, это не работает.

1 Ответ

0 голосов
/ 22 мая 2018
(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))
...