I am using Jess 6.

I tried to do the following which works:
(bind ?john (assert (user (name john))))

and then do that which doesn't work:
(assert (user-location (user ?john) (location A)))

So based on what you said, i can't figure what's wrong in what i did.


-----Message d'origine-----
De : friedman_hill ernest j [mailto:[EMAIL PROTECTED]]
Envoye : mardi 13 mars 2001 17:22
A : =?iso-8859-1?Q?J=E9r=F4me_BERNARD?=
Cc : [EMAIL PROTECTED]
Objet : Re: JESS: How to have a slot value being a reference to another
object?


In previous versions of Jess, you'd have to use a slot in "user" as a
sort of identifier; i.e., user-location's user slot could contain the
name of a user. You can't use a numeric fact-id, because those change
when the fact is modified. Then when you write a rule, you have to
match on that slot

(defrule move-user-to-location-A
  (user (name ?name))
  =>
  (assert (user-location (user ?name) (location A))))

(defrule process-user-at-location-A
  (user-location (user ?name) (location A))
  ?u <- (user (name ?name))
  =>
  (do-something-to ?u))

In Jess 6.x, bound fact ids like ?u are actually references to Fact
objects, not just numbers (although they can be easily, and sometimes
transparently, converted to numbers.) So in Jess 6, you can do

(defrule move-user-to-location-A
  ?u <- (user)
  =>
  (assert (user-location (user ?u) (location A))))

(defrule process-user-at-location-A
  ?u <- (user)
  (user-location (user ?u) (location A))
  =>
  (do-something-to ?u))


I think =?iso-8859-1?Q?J=E9r=F4me_BERNARD?= wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi all!
>
> I have defined 3 objects such as those ones.
> (deftemplate user (slot name) )
> (deftemplate product (slot productID) (slot location) )
> (deftemplate user-location (slot user) (slot location) )
>
> And have asserted the following facts:
> (assert(product (productID 1) (location A)))
> (assert(product (productID 2) (location B)))
> (assert(product (productID 3) (location C)))
> (assert(user (name john)))
> (assert(user (name foo)))
> (assert(user (name bar)))
>
>
> Now what I want to do is to assert a user-location fact such as the user
> slot would be the refence to one of the asserted users and the location
> would be a simple string.
> I tried to bind the fact id to a variable, but then since I have a fact id
> and not a reference, I don't know what to do with it.
>
> I am probably going into the wrong way, but i can't figure out how to
solve
> that...
>
> Can someone help me?
>
>
> Thank you in advance.
>
> Regards,
> J_r_me BERNARD.
>
>
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
>



---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550


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