I think Conor Power wrote:
> 
> Hi,
>  I have a question regarding how to use the attribute
> of a java object in the LHS of a rule.
> 
...
> I want a rule to fire depending on the value of the cmp member variable
> 
> I envisage using something like follows
> 
> (defrule r1
>       (get ?*x* cmp)
>       =>
>       (DO SOMETHING)
> )
> 
> Is this okay??


No - the things on the left side of a rule are always patterns, never
function calls. WHaqt you've written would match a fact with the head
'get' and two fields with the given values.

> 
> The next problem I have is that, I set the member variable cmp in the
> right side
> of another rule. In this situation will the above rule check (get) the
> new value and
> test it. Do I need to add "notify changed" functions to the Foo object?
> 
> Is my methodology correct?

You can only match properties of Java Beans on rule LHSs. The Beans
must have propertyChangeListener support. Study the
jess/examples/pumps/ example to learn the details. 

The reason for this is simple, and I think you have an inkling of it
here: Jess has to have some way of knowing when a property's value
changes, or else it couldn't use the Rete algorithm to match the
property: it would have to poll it, I suppose, which would be silly.


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (510) 294-2154
Sandia National Labs                FAX:   (510) 294-2234
Org. 8920, MS 9214                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to