I think Sebastian Mayer wrote:
>
> r.executeCommand("(call "point" setLocation 2,2)");
>
> Of course this is not possible, but how should i access the stored Point object?
r.executeCommand("(call (fetch point) setLocation 2 2)");
Note that I removed an extraneous comma as well. This could be
shortened by omitting the "call", which is always legal if the target
is a Java object:
r.executeCommand("((fetch point) setLocation 2 2)");
> and even if i solve the mentioned problem: when i give the Value
> back to the Java Program, how can i get the Point out of the Value
> object? (the getExternalAddressValue( Context c ) looks a little
> strange, i didn't get the idea of the context )
Strange, perhaps, but that's what you do.
Point p = (Point) r.fetch("point").externalAddress(r.getGlobalContext());
> B) i try it with defclass ( like the antetype out of the jess manual)
>
> Rete r=new Rete();
> Point pt1=new Point(1,1);
> r.store("PointName",pt1);
> r.executeCommand("(defclass Point java.awt.Point)");
> r.executeCommand("(definstance Point (fetch PointName) static)");
>
> but then how procede? (again i want to use the setLocation method of the Point
> object in some time)
Having done this, the Point appears in working memory (try issuing the
"(facts)" command). Now you can write rules that respond to the values
of the Point's properties. The shadow fact representing the point will
have slots for the x, y, and location properties, because of the
getX(), getY(), and getLocation() methods. Unfortunately, there are no
setX() and setY() methods, and the setLocation(Point) is the only one
of the three overloads that looks like a JavaBeans property. This
class wan't designed as a JavaBean! But in any case, you can write
rules like
(defrule move-point-down-and-right
?p <- (Point (x ?x) (y ?y))
=>
(modify ?p (x (+ ?x 1)) (y (+ ?y 1))))
---------------------------------------------------------
Ernest Friedman-Hill
Science and Engineering PSEs Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
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]
--------------------------------------------------------------------