Question

I have embedded CLIPS into C Language. I have situation like this: in a .clp file, I have fact list

(deftemplate sensor
 (slot name) 
 (slot status)) 

(deffacts FRONTSENSOR
(sensor (name 1) (status 1))
(sensor (name 2) (status 1))
(sensor (name 3) (status 0))
(sensor (name 4) (status 0))
(sensor (name 5) (status 1))
(sensor (name 6) (status 0))
(sensor (name 7) (status 0))
(sensor (name 8) (status 0))) 

now I want to cancel these facts and assert new facts in to the list. I use Retract(factPtr); to cancel facts and use AssertString("(sensor (name 1) (status 0))"); to assert fact. And I print the fact list, result is

f-0     (initial-fact)
f-11    (sensor (name 1) (status 0))
f-12    (sensor (name 2) (status 0))
f-13    (sensor (name 3) (status 1))
f-14    (sensor (name 4) (status 0))
f-15    (sensor (name 5) (status 0))
f-16    (sensor (name 6) (status 0))
f-17    (sensor (name 7) (status 1))
f-18    (sensor (name 8) (status 1))
For a total of 9 facts.

the fact-index is start from 11 instead of 1, I wonder if there is function or solution that the new asserted fact can start from f-1. Ps:Clear()function can reset the fact-index, but the rules will also be cleaned. It seems not helpful.

Thank for answers or any ideas.

Was it helpful?

Solution

The Reset() function will remove all the facts and reset the fact-indices without removing any of the rules.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top