getting a handle on fact in RHS

View: New views
1 Messages — Rating Filter:   Alert me  

getting a handle on fact in RHS

by axelrad :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I have a template that has a fact as a slot.

ex)

(deftemplate mainfact
(slot subfact (type OBEJCT))
(slot index))

(deftemplate subfact
(slot name)
(slot content))

I have a rule that instantiates (assert) the mainfact and subfact if my condition is met. My problem is that if the subfact exists already it gets asserted to false. What I need is to get a handle on the fact if it exists and assert the mainfact with the existing subfact and a new current index.
What I do now is along the lines of:

assert mainfact (subfact xxx) (index n)

works great if the subfact doesn't exist yet: mainfact xxx n
but if the subfact exists my result is: mainfact (false) (n)

what i need is : mainfact (existing fact) (n)

I need to compare the subfacts for when they are the same and keep the one with the higher index value. I've tried doing a query and putting that value in but i get a jess query object instead of a fact object, and later when i need to compare the values they are not considered the same object, even if the slot values are correct, so I don't get the correct results when trying to keep the mainfact with higher index value.

I can test if the fact exists already, but how can I get a handle on it to place that value in the slot?

Thanks in advance for any help!

Monica