One way to do this would be to use "progn" in a test CE:

(defrule x
  (theShadowFact (OBJECT ?o))
  (test (progn
          (bind ?xyz (?o getXYZ))
          (and (> ?xyz 10)
               (< ?xyz 100))))
  => ...

"progn" executes all the function calls inside it, then returns the value of the last one.


On Jan 15, 2007, at 4:00 PM, Skeptic 2000 wrote:

Hi,

In the LHS of a rule, could I bind to a variable a object that is returned from a method called on a matched fact ?


(rule x
(theShadowfact ?o)
(... ?o getXYZ ... )

The purpose of doing this is to have a variable on which to do some tests without having to call getXYZ for each one of them.

Thanks


> From: [EMAIL PROTECTED]
> Subject: Re: JESS: calling a method on a matched shadow fact
> Date: Fri, 3 Nov 2006 00:46:42 -0500
> To: jess-users@sandia.gov
>
> On Nov 2, 2006, at 1:29 PM, Skeptic 2000 wrote:
>
>
> >
> > Let's say I have something like :
> >
> > (defclass xyz x.y.com.XYZ)
> >
> > (defrule "x"
> > ?x<-(xyz)
> > =>
> > (...)
> >
> > In the RHS, I would like to call a method that is not a bean get/
> > set on the matched 'xyz', what would be the proper way? (If
> > possible, this method would take a string as argument)
> >
>
> ?x is a jess.Fact object; it has a slot named OBJECT containing the
> actual XYZ object. So you could say
>
> ((?x getSlotValue OBJECT) theMethodName "the argument")
>
> Alternatively, you could bind the OBJECT slot on the LHS, and then
> you'd have a variable on which you could call the method directly.
>
> ---------------------------------------------------------
> 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 owner-jess- [EMAIL PROTECTED]
> --------------------------------------------------------------------
>


Soyez parmi les premiers à essayer Windows Live Mail.

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