Aha, said the blind man! :) I really did copy\paste Dusan's rule. But, I pasted just the rule into my program. And in my program I was asserting the facts before defining the rule and apparently that makes quite a difference. Now, let me see if I can grok why that is. This was just a simplified example to pose the question in. In the real application I'm working towards, I'll be loading the rules from a .clp file and then asserting the facts from a Java application. So, I think this will be OK. Thank you both very much!
Eric -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, February 14, 2006 12:03 PM To: jess-users@sandia.gov Subject: Re: JESS: Getting Facts in Sorted Order I think Eric W. Bonnett wrote: > Hmm, I don't think so. Copy\paste! :) I should have mentioned it > before, I'm using the publicly available version 6.1p4 that I downloaded > based on instructions in the book. On the off chance that there was something about this version, I tried it myself -- but it worked fine. Here's the program I ran: (deftemplate SomethingIWant "Stuff I want" (slot Name (default Whatever) ) (slot Price (default 10) ) (slot Priority (default 0) ) (slot Selected (default false) ) ) (defrule items-to-buy ?ItemFound <- (SomethingIWant (Name ?ItemName) (Price ?ItemPrice) (Priority ?ItemPriority1) (Selected false ) ) (not (SomethingIWant (Selected false) (Priority ?p&:(< ?p ?ItemPriority1)))) => (printout t "Found: " ?ItemName ", " ?ItemPrice ", " ?ItemPriority1 crlf) (modify ?ItemFound (Selected true) ) ) (assert (SomethingIWant (Name "TiVo") (Price 200) (Priority 1) ) ) (assert (SomethingIWant (Name "Tires") (Price 800) (Priority 1) ) ) (assert (SomethingIWant (Name "Carb") (Price 400) (Priority 1) ) ) (assert (SomethingIWant (Name "DVD Burner") (Price 400) (Priority 5) ) ) (assert (SomethingIWant (Name "Wheels") (Price 1000) (Priority 2) ) ) (assert (SomethingIWant (Name "shocks") (Price 900) (Priority 2) ) ) (run) And here's the output: Found: Carb, 400, 1 Found: Tires, 800, 1 Found: TiVo, 200, 1 Found: shocks, 900, 2 Found: Wheels, 1000, 2 Found: DVD Burner, 400, 5 --------------------------------------------------------- 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] -------------------------------------------------------------------- -------------------------------------------------------------------- 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] --------------------------------------------------------------------