Re: JESS: Get fact's slot value

Gaëtan Pruvost <[email protected]>
Newsgroups gmane.comp.java.jess
Message-ID <[email protected]>
Hello,

I agree with John, you should take a course through the tutorials first, 
it would help you a lot.
Now, in your question, it seems that you need to access the slot of a 
specific fact that you've just bound.
In this case, you can access slots directly with a "." (like an object 
field):

(deftemplate person (slot name (type STRING)) (slot age (type INTEGER)))
(bind ?new (assert (person (name Fred) (age 22))))
(printout t ?new.name)


Now, if you want to list the names of every person facts, then you would 
have to use defQuery to enumerate them.

***********************************
Gaëtan PRUVOST

LIMSI-CNRS BP 133
91403 Orsay Cedex France
Tel:+33 1 69858110

http://www.limsi.fr/Individu/pruvost/
***********************************


Le 22/11/2010 15:57, John Everett a écrit :
> Jess is a rule language whose basic mechanism is pattern matching, which
> binds pattern variables to constants. If you have a fact of the form
>
> (person (name Fred) (age 22))
>
> then you can issue a query of the form
>
> (person (name ?name) (age ?age))
>
> and it will bind ?name to Fred and ?age to 22 (if Fred is the only person in
> your database).
>
> You can do this with a defQuery or a rule. As you're new to Jess, you really
> ought to work your way through some of the tutorial material available, as
> Jess (and rule engines in general) operate quite differently from
> conventional programming languages.  You can learn quite a lot from the Jess
> manual in a few hours of poking around.
>
> -John
>
> -----Original Message-----
> From: alvin0618 [mailto:[email protected]]
> Sent: Monday, November 22, 2010 9:47 AM
> To: [email protected]
> Subject: JESS: Get fact's slot value
>
>
> (deftemplate person (slot name (type STRING)) (slot age (type INTEGER)))
>
> (bind ?new (assert (person (name Fred) (age 22))))
>
> =================================================
> The question is how do i get the binded fact's slot value, name and age???
> Could any provide help to me~
> I'm new in JESS language
gaetan_pruvost.vcf (text/plain, 188 B)
begin:vcard
fn;quoted-printable:Ga=C3=ABtan Pruvost
n;quoted-printable:Pruvost;Ga=C3=ABtan
email;internet:[email protected]
tel;work:+33 1
x-mozilla-html:TRUE
version:2.1
end:vcard
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.