In the following rule, which is stored in file among others, I’m reading numbers (separated by space) one by one from file, and stacking them into array (or other structure, I’m not sure).But during run it says “[ROUTER1] Logical name ‘TRUE’ was not recognized by any routers. [PRCCODE4] Execution halted during the actions of defrule ‘read-numbers’.”
(defrule read-numbers
(declare (salience 100))
=>
(bind ?numbers (open "numbers.txt" "r"))
(if (neq ?numbers FALSE)
then
(bind ?index 1)
(bind ?temp (read ?numbers))
(while (neq ?temp EOF)
do
(bind ?*numbers* (insert$ ?*numbers* ?index ?temp))
(bind ?index (+ ?index 1)))
(bind ?temp (read ?numbers)
)
(bind ?*num-count* (- ?index 1))
(close ?numbers)
(printout t "Array:" crlf)
(loop-for-count (?i 1 ?*num-count*)
(printout t (nth$ ?i ?*numbers*) " "))
(printout t crlf)
else
(printout t "Failed to open file 'numbers.txt'." crlf)))
I also tried to make (println TRUE) in the same file, and it really printed TRUE, so there must be no problem with the compiler.
Also, after manual debug with prints I found out that it happens somewhere here:
(while (neq ?temp EOF)
Robert Outburst is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.