Rick

There area two errors in this code that are stopping it from working: in the deffacts you are using station instead of gym-station; and in the rule line (gym-station (ident ?any) (purpose ?alist) ), the ?alist should be $?alist to indicate that it should be treated as a multislot, which should then cause the member$ function to work correctly. I attach below the revised code that seems to work fine.

David


(deftemplate gym-station (slot ident) (multislot purpose))
(deftemplate gym-station (slot ident) (multislot purpose))

(deffacts gym-station-data
(gym-station (ident s1) (purpose arms-upperfront back))
(gym-station (ident s2) (purpose legs abs))
(gym-station (ident s3) (purpose abs shoulders arms-upperfront)))

(defrule detect-arms-upperfront
(gym-station (ident ?any) (purpose $?alist) )
=>
(if (member$ arms-upperfront ?alist) then
   (printout t " Found arms-upperfront " ?any crlf )
else
   (printout t " None found "  crlf)))

(reset)(run)

ricktee wrote:
Hi, I'm working on a school project using JESS 6.1 and using the "JESS in
action" as my manual.
I got 3 "gym-machine" facts, each with 2 slots they are "ident" and
"purpose"

I'm trying to write a rule that checks all 3 facts's "purpose" slot for the
existent of "arms-upperfront"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftemplate gym-station (slot ident) (multislot purpose))

(deffacts gym-station-data
(station (ident s1) (purpose arms-upperfront back))
(station (ident s2) (purpose legs abs))
(station (ident s3) (purpose abs shoulders arms-upperfront)))

(defrule detect-arms-upperfront
(gym-station (ident ?any) (purpose ?alist) )
=>
(if (member$ arms-upperfront ?alist) then
        (printout t " Found arms-upperfront " ?any )
else
        (printout t " None found " )))

(reset)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I'm having trouble at the defrule (gym-station (ident ?any)
it seems I can't use ?any to represent all 3 facts. I'm trying to get the
rule to cycle through all 3 facts. I have try to remove (ident ?any) but it
still wont cycle through the 3 facts. Please help me, am I writing it the
wrong way?

Thank you very much for your time
Rick

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