First, you bind to the contained object, and then you locate the containing
object.

(defrule mydoor
   ?door <- (Door (weight ?weight)(color ?color))
                  (House (myDoor ?door)(owner "Mick"))
=>
   (printout t "Weight of Mick's door :" ?weight crlf)
)

Restrictions on weight or color, e.g., to paint red doors black ;-) can be
added in the usual way.

-W


On Fri, Aug 21, 2009 at 12:12 PM, Romain Van der Keilen <
[email protected]> wrote:

> Hi there,
>
> I have a little question for you I can't fix by myself: how to access the
> fields of a java Object that is itself a field of an other java object?
> Here is a tiny sample :
>
> Object Door
>  + int weight
>  + String color
>
> Object House
>  + Door myDoor
>
> Now I give the House to the Rete engine, how can I access (and manipulate)
> for example the weight of my door?
>
> By now I just can display it like this:
> (defrule mydoor
>    (House (myDoor ?myDoor))
>    =>
>    (printout t "Weight of my house's door :" ?myDoor.weight crlf)
> )
> But the thing I want to do is to catch that weight to make some checks on
> it, then displaying the checks' results (for examples, is my door heavier
> than 25kg).
>
> Thanks for help
>
> Romain Van der Keilen
>
>
>
> --------------------------------------------------------------------
> 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