Let's say for example I have the following facts
(deffacts num
(number 4)
(number 5)
(number 9)
)
Create an empty variable
(bind ?numbers (create$)
)
And have the following rule to try to add each number to the variable
(defrule build-numbers
?number-fact<-(number ?c)
=>
(bind ?numbers (insert$ ?numbers 999 ?c))
(retract ?number-fact)
)
If I check before runing if the variable is properly bound by printing it, i get no error
(printout t "Numbers " ?numbers crlf
)
However when I run the example, I get the following error
[PRCCODE5] Variable numbers unbound.
[PRCCODE4] Execution halted during the actions of defrule build-numbers.
I notice the variable getting unbound after doing a (reset), so I bind it afterwards, but why does it also unbind when doing (run)? Is there a way around this?