When I try to modify a fact created from a definstance of a Java bean that has 
property change support the fact does not get modified right away if the defistance 
function was called with the static parameter. Using the Simple.java bean that comes 
with Jess, here are the steps that I took and the results.


When creating the fact using definstance with the dynamic parameter the modify 
function seems to work

C:\amber\Jess\Jess60>java -cp .  jess.Main

Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.0 12/7/2001

Jess> (defclass simple jess.examples.simple.Simple)
jess.examples.simple.Simple
Jess> (ppdeftemplate simple)
"(deftemplate MAIN::simple extends MAIN::__fact \"$JAVA-OBJECT$ 
jess.examples.simple.Simple\"
 (slot class (default <External-Address:jess.SerializablePD>))
 (slot fraction (default <External-Address:jess.SerializablePD>))
 (slot name (default <External-Address:jess.SerializablePD>))
 (slot serial (default <External-Address:jess.SerializablePD>))
 (slot truth (default <External-Address:jess.SerializablePD>))
 (slot OBJECT (type 2048)))"
Jess>  (bind ?sb (new jess.examples.simple.Simple Dave))
<External-Address:jess.examples.simple.Simple>
Jess> (definstance simple ?sb dynamic)
<Fact-0>
Jess> (facts)
f-0   (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Dave") (serial 0) (truth FALSE) (OBJECT 
<External-Address:jess.examples.simple.Simple>))
For a total of 1 facts.
Jess> (defrule change_name ?f <- (simple (name "Dave")) => (modify ?f (name "Tom")))
TRUE
Jess> (rules)
MAIN::change_name
For a total of 1 rules.
Jess> (ppdefrule change_name)
"(defrule MAIN::change_name
   ?f <- (MAIN::simple (name \"Dave\"))
   =>
   (modify ?f (name \"Tom\")))"
Jess> (watch all)
TRUE
Jess> (run)
FIRE 1 MAIN::change_name f-0
 <== f-0 (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Dave") (serial 0) (truth FALSE)
(OBJECT <External-Address:jess.examples.simple.Simple>))
 ==> f-0 (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Tom") (serial 0) (truth FALSE) (OBJECT 
<External-Address:jess.examples.simple.Simple>))
1
Jess> (facts)
f-0   (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Tom") (serial 0) (truth FALSE) (OBJECT 
<External-Address:jess.examples.simple.Simple>))
For a total of 1 facts.
Jess> (jess-version-number)
6.0
Jess>

When creating the fact using definstance with the static parameter the modify function 
does not seem to work

C:\amber\Jess\Jess60>java -cp .  jess.Main

Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.0 12/7/2001

Jess> (defclass simple jess.examples.simple.Simple)
jess.examples.simple.Simple
Jess> (ppdeftemplate simple)
"(deftemplate MAIN::simple extends MAIN::__fact \"$JAVA-OBJECT$ 
jess.examples.simple.Simple\"
 (slot class (default <External-Address:jess.SerializablePD>))
 (slot fraction (default <External-Address:jess.SerializablePD>))
 (slot name (default <External-Address:jess.SerializablePD>))
 (slot serial (default <External-Address:jess.SerializablePD>))
 (slot truth (default <External-Address:jess.SerializablePD>))
 (slot OBJECT (type 2048)))"
Jess>  (bind ?sb (new jess.examples.simple.Simple Dave))
<External-Address:jess.examples.simple.Simple>
Jess> (definstance simple ?sb static)
<Fact-0>
Jess> (facts)
f-0   (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Dave") (serial 0) (truth FALSE) (OBJECT 
<External-Address:jess.examples.simple.Simple>))
For a total of 1 facts.
Jess> (defrule change_name ?f <- (simple (name "Dave")) => (modify ?f (name "Tom")))
TRUE
Jess> (rules)
MAIN::change_name
For a total of 1 rules.
Jess> (ppdefrule change_name)
"(defrule MAIN::change_name
   ?f <- (MAIN::simple (name \"Dave\"))
   =>
   (modify ?f (name \"Tom\")))"
Jess> (watch all)
TRUE
Jess> (run)
FIRE 1 MAIN::change_name f-0
1
Jess> (facts)
f-0   (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Dave") (serial 0) (truth FALSE) (OBJECT 
<External-Address:jess.examples.simple.Simple>))
For a total of 1 facts.
C:\amber\Jess\Jess60>java -cp .  jess.Main

Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.0 12/7/2001

Jess> (defclass simple jess.examples.simple.Simple)
jess.examples.simple.Simple
Jess> (ppdeftemplate simple)
"(deftemplate MAIN::simple extends MAIN::__fact \"$JAVA-OBJECT$ 
jess.examples.simple.Simple\"
 (slot class (default <External-Address:jess.SerializablePD>))
 (slot fraction (default <External-Address:jess.SerializablePD>))
 (slot name (default <External-Address:jess.SerializablePD>))
 (slot serial (default <External-Address:jess.SerializablePD>))
 (slot truth (default <External-Address:jess.SerializablePD>))
 (slot OBJECT (type 2048)))"
Jess>  (bind ?sb (new jess.examples.simple.Simple Dave))
<External-Address:jess.examples.simple.Simple>
Jess> (definstance simple ?sb static)
<Fact-0>
Jess> (facts)
f-0   (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Dave") (serial 0) (truth FALSE) (OBJECT 
<External-Address:jess.examples.simple.Simple>))
For a total of 1 facts.
Jess> (defrule change_name ?f <- (simple (name "Dave")) => (modify ?f (name "Tom")))
TRUE
Jess> (rules)
MAIN::change_name
For a total of 1 rules.
Jess> (ppdefrule change_name)
"(defrule MAIN::change_name
   ?f <- (MAIN::simple (name \"Dave\"))
   =>
   (modify ?f (name \"Tom\")))"
Jess> (watch all)
TRUE
Jess> (run)
FIRE 1 MAIN::change_name f-0
1
Jess> (facts)
f-0   (MAIN::simple (class <External-Address:java.lang.Class>) (fraction 0.0) (name 
"Dave") (serial 0) (truth FALSE) (OBJECT 
<External-Address:jess.examples.simple.Simple>))
For a total of 1 facts.


My understaing is that the modify functionMop is suppose to modify a  fact directly 
whether the fact was created with property support or not.

When I modify a fact that was created without the use of the definstance funtion the 
fact gets modified right away.

C:\amber\Jess\Jess60>java -cp .  jess.Main

Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.0 12/7/2001

Jess> (assert (shopping-list milk eggs tp bread butter))
<Fact-0>
Jess> (facts)
f-0   (MAIN::shopping-list milk eggs tp bread butter)
For a total of 1 facts.
Jess> (defrule remove-bread ?f <- (shopping-list $?head bread $?tail) => (modify ?f 
(__data $?head $?tail)))
TRUE
Jess> (rules)
MAIN::remove-bread
For a total of 1 rules.
Jess> (ppdefrule remove-bread)
"(defrule MAIN::remove-bread
   ?f <- (MAIN::shopping-list $?head bread $?tail)
   =>
   (modify ?f (__data $?head $?tail)))"
Jess> (watch all)
TRUE
Jess> (run)
FIRE 1 MAIN::remove-bread f-0
1
Jess> (facts)
f-0   (MAIN::shopping-list milk eggs tp butter)
For a total of 1 facts.





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