I've found the solution for it however it keeps firing continuously and when
I replace 'test' with
'exists' to make the rule fire once only it doesn't activate the rule at all
(although I have reset
the facts to say John is Mr)

(defrule changeAncestorJohnTitle
"Need to change Bart's ancestor John title to Dr"
?bart<- (Person (Name Bart)(Ancestors $?ancestors))
?p <- (Person (Name John))
(test (member$ ?p ?ancestors))
=>
(modify ?p (Title Dr))
(printout t ?p crlf))

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of portalguy
Sent: 17 January 2005 19:16
To: [email protected]
Subject: JESS: Modifying a multislot value of type instance


Hi,
I have template called Person which has a multislot called Ancestors. I've
inserted a fact of type Person called
Bart who has 3 ancestors (Tom,John,Jane). Basically I need to change the
ancestor 'John' title. I wrote the rule below but I can't get it to fire.

(deftemplate Person
(slot Name (type STRING))
(slot Title (type STRING))
(multislot Ancestors)
)

(assert (Person (Name Bart)(Ancestors (create$ (assert (Person (Name
Tom)(Title Mr))) (assert (Person (Name John)(Title Mr)))(assert (Person
(Name Jane)(Title Mrs)))))))

(defrule changeAncestorJohnTitle
"Need to change Bart's ancestor John title to Dr"
?bart<- (Person (Name Bart)(Ancestors $?ancestors))
?index<-(member$ ?p ?ancestors&:(?p (Person (Name John))))
?john<- (nth$ ?index ?ancestors)
=>
(printout t ?john crlf)
(printout t ?ancestors crlf))


any help is appreciated
thanks

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to