>> How does one write this rule and fire it (from commandline as well as
>> from Java code)

You are almost there.  From the Jess prompt, you just need to make the rule:

(defrule testRule
  (automobile (make Chrysler))
  =>
  (match))

add a (reset) command, do the assert of the type of automobile and run. I
have included the sequence below.  Note the (reset) command and that the
assert comes after the (reset).

In java, an overly simplified approach would be

   Rete r = new Rete();
   r.executeCommand("....")  where you insert each of your commands here

This is of course not very useful. But if you look at the api documentation
(http://herzberg.ca.sandia.gov/jess/docs/70/api/index.html) you will find
that there are better ways to do this and there is a **lot** more that you
can do. The documentation on the jess site is excellent and very easy to
read by the way.  The interaction between Jess and Java is very easy.


-Timothy

(deftemplate automobile
   "A specific car."
   (slot make)
   (slot model)
   (slot year (type INTEGER))
   (slot color (default white)))


(deffunction match () ( printout t "Match occured..." crlf))

(defrule testRule
  (automobile (make Chrysler))
  =>
  (match))

(reset)

(assert (automobile (make Chrysler) (model LeBaron)
        (year 1997)))

(run)

--------------------------------------------------------------------
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