Are you asking how to write a rule that performs some test on the weight of a door? The "dotted variable" notation is a recently- introduce shorthand that won't work on the left-hand-sides of rules; but you can use the older "get-member" function:

(defrule mydoor
   (House (myDoor ?myDoor&:(> (get-member ?myDoor weight) 25)))
   =>
   (printout t "Weight of my house's door :" ?myDoor.weight crlf)
)

The name "get-member" is quite unwieldly, and you might want to replace it with a custom "weight" function like

(deffunction weight (?door)
    (return (get-member ?door weight)))

Then you could write the pattern as

   (House (myDoor ?myDoor&:(> (weight ?myDoor) 25)))


On Aug 21, 2009, at 6:12 AM, Romain Van der Keilen 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

--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
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