No comment?

Florian Fischer wrote:
Hello,

In the rather simple program below, I get as output

   Jess Version 7.0p1 12/21/2006
   ----------------- defrules
   ----------------- assert
   Assert user-right
   ----------------- retracts
   retracting
   ----------------- re-defrule
   Retract user right

While I would expect

   Jess Version 7.0p1 12/21/2006
   ----------------- defrules
   ----------------- assert
   Assert user-right
   ----------------- retracts
   retracting
   Retract user right
   ----------------- re-defrule

The "remove" rule doesn't fire, unless I reenter the exact same rule. Any ideas?

Regards,
Florian Fischer

---------------------------------- CUT HERE -----------------------------

(deftemplate def-right
(slot user)
(slot accessRight)
)

(deftemplate user-right
(slot clientId)
(slot userInitials)
(slot accessRight)
)

(deftemplate client3
(slot id)
(slot userInitials)
)

;---------------------------

(printout t (jess-version-string) crlf)

(printout t "----------------- defrules" crlf)
(defrule debug-add-right
(client3 (id ?clientId) (userInitials ?init&~nil))
(def-right (user ?init) (accessRight ?right) )
(not (user-right (clientId ?clientId) (userInitials ?init) (accessRight ?right)) )
=>
(printout t "Assert user-right" crlf);
(assert (user-right (clientId ?clientId) (userInitials ?init) (accessRight ?right)) )
)

(defrule debug-remove-right
?f <- (user-right (clientId ?clientId) (userInitials ?init) (accessRight ?right) )
(not (and
          (client3 (id ?clientId) (userInitials ?init&~nil))
          (def-right (user ?init) (accessRight ?right) )
)    )
=>
(printout t "Retract user right" crlf);
(retract ?f)
)
(run)

(printout t "----------------- assert" crlf)
(assert
  (client3 (id "123") (userInitials "fnf"))
  (def-right (user "fnf") (accessRight "EDIT"))
)
(run)

(printout t "----------------- retracts" crlf)
(defrule tmp
?f <- (def-right (user "fnf"))
=>
(printout t "retracting" crlf)
(retract ?f)
)
(run)
(undefrule tmp)

(printout t "----------------- re-defrule" crlf)
(defrule debug-remove-right
?f <- (user-right (clientId ?clientId) (userInitials ?init) (accessRight ?right) )
(not (and
          (client3 (id ?clientId) (userInitials ?init&~nil))
          (def-right (user ?init) (accessRight ?right) )
)    )
=>
(printout t "Retract user right" crlf);
(retract ?f)
)
(run)

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