On Dec 20, 2006, at 4:48 AM, jaggie wrote:


//I want to call the function warning in the RHS but without creating a new instantiation of the bean, I want to call the warning from the variable ?da
defined up there.


The template "agent", like all templates created from Java classes, has a slot OBJECT, which will contain the Java object that the shadow fact is connected to. So match the OBJECT slot to a variable on the LHS, and then you can call a method of the object on the RHS:

 (defrule watchlife
     (agent {life < 70} (OBJECT ?da))
     =>
     (?da warning))

I also rewrote your LHS using the new Jess 7 test syntax, which is much cleaner.


---------------------------------------------------------
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://www.jessrules.com
--------------------------------------------------------------------
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