I think Brett Daniel wrote: > (defrule isInList > ?response <-(Response (s1 ?x)) > (not (test ((new SumObject "c:/dev/data/data.txt") InList ?x)) > ) > => (printout t "It does exist") > )
> Q. When is the [SumObject] created and the text file loaded? When the rule is > built or when it fires? The function in a "test" CE is called every time the "test" CE is processed. A test CE is processed every time the preceding pattern is matched -- in this case, every time a "Response" fact is asserted. So this isn't especially efficient -- it's reading in your file once for each Response fact! > > Q. Is there a way to instantiate SumObject outside the rule and reference it > in the test statement? Sure -- you could put it in a defglobal, or else make it accessible via a Java function call. Using a defglobal, it looks like this: (defglobal ?*sum* = (new SumObject "c:/dev/data/data.txt")) (defrule isInList ?response <- (Response (s1 ?x)) (test (not (?*sum* InList ?x))) => (printout t "It does (not?) exist" crlf)) It's actually cheaper if you turn things inside out as I've shown, with the "not" inside the "test". --------------------------------------------------------- Ernest Friedman-Hill Advanced Software Research 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] --------------------------------------------------------------------