I think chris poppe wrote: > Hello, > > thanks for the quick response and there was indeed something i left out of > the rule (for simplicity). I was calling the setMessage() method from the > object so I guess that's what makes the rule fire twice, so is there a way > that I can still alter the slots of the object in my rule but witouth having > it fired again? > > greetings Chris >
Unfortunately, it's not easy in current versions of Jess. The standard way is to assert a fact of some kind to "remember" that you've already fired on a given object, and then match "not" that fact on the rule LHS. People are probably tired of hearing this (or maybe not,) but in the upcoming Jess 7, there will be a couple of easy ways to do this. One is the no-loop declaration. (defrule not-an-infinite-loop (declare (no-loop TRUE)) ?s <- (sum (value ?v)) => (modify ?s (+ ?v 1))) Any rule that declares the no-loop property won't be activated a second time by any actions taken on the RHS. Another technique is to use the "slot-specific" declaration for deftemplates: (deftemplate sum (declare (slot-specific TRUE)) (slot value) (slot comment)) (defrule not-an-infinite-loop-2 ?s <- (sum (value ?v)) => (modify ?s (comment "Saw this one"))) No rule will be activated by changes to the slot values of a slot-specific template's facts except for slots explicitly mentioned on the rule's LHS. These are already functional. It's quite possible that either or both of these will be renamed before the release. --------------------------------------------------------- Ernest Friedman-Hill Science and Engineering PSEs Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov -------------------------------------------------------------------- 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] --------------------------------------------------------------------
