Search code examples
clips

can i retrieve fact's value after searching for it? Clips


I know how to search to check whether fact slot exists, I need to know how to obtain the value of other slots in that fact

  (deftemplate details
(slot name(type STRING))(slot occ (type STRING))......)
and 
(deffacts details
    (details (occ "student")(name "mike"))
    (details (occ "professor")(name "john"))
   .......
)

(defrule search

(userinfo(occ?occ)) (details(occ?occ) )

 =>

????????????????????????? )


Solution

  • Just bind them in the conditions of the rule:

    (defrule search
       (userinfo (occ ?occ)) 
       (details (occ ?occ) (name ?name))
       =>
       (printout t "Name is " ?name crlf))