Hello,

Maybe there is a simple reason for this, but I don't see it.
In the code at the bottom, query-1 with argument "bar" doesn't return any result, while query-2 returns the expected 2 facts also given by the equivant rule tmp.

Any way to make it work?  I came up with
   (right (user ?u&:(member$ ?u (create$ ?user "*"))) )
which is not really elegant.  Any better suggestion?

I am using JESS 6.

Thanks in advance, and best regards,
Florian Fischer

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

(deftemplate right (slot resource) (slot user) (slot access) )

(assert
 (right (resource "A") (user "*") (access "read"))
 (right (resource "A") (user "foo") (access "read-write"))
 (right (resource "B") (user "bar") (access "read-write"))
)

(defrule tmp
 ?f <- (right (user "bar"|"*"))
 =>
 (printout t (?f toString) crlf)
)
(run)
(undefrule tmp)
(printout t "------" crlf)

(defquery query-1
 "get the rights for a user"
 (declare (variables ?user))
 (right (user ?user|"*"))
)

(defquery query-2
 "get the rights for user bar"
 (declare (variables ?user))
 (right (user "bar"|"*"))
)

(bind ?it (run-query query-1 "bar"))
(while (?it hasNext)
   (bind ?token (call ?it next))
   (bind ?fact (call ?token fact 1))
   (printout t (?fact toString) crlf)
)

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