I think that Lars Hubner wrote: >>There a two things wrong, I think: Oh beware the dangers of late night cut & paste programming! The correct code should have been
(clear) (watch all) (deftemplate adv-attributes (slot id) (multislot attribs)) ;; Yes, you need a rule name (defrule show-adv-attributes "This rule matches all adv-attributes facts and binds their id and attribute slots to variables" ?fact <- (adv-attributes (id ?id) (attribs $?attribs)) => (printout t "-------------------------" crlf) (printout t "Fact-id=" ?fact crlf) (printout t "id=" ?id crlf) (printout t "attribs=" ?attribs crlf)) (reset) (assert (adv-attributes (id 1) (attribs radio-advertisement low-budget))) (assert (adv-attributes (id 2) (attribs radio-advertisement control-message-frequency))) (run) This indeed runs as advertised. Sorry about that! -JM ------------------------ Jason Morris Morris Technical Solutions [EMAIL PROTECTED] www.morristechnicalsolutions.com fax/phone: 503.692.1088 > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Lars H|bner > Sent: Monday, August 09, 2004 1:20 AM > To: [EMAIL PROTECTED] > Subject: AW: JESS: How to match Pattern in Facts > > > I think Calvin Pevee wrote: > > > (defrule > > (adv-attribute radio-advertisement ?x) > > => > > Maybe it is usefull, to give the rules a name??? > > > I think Jason Morris wrote: > > > (defrule print-adv-attributes-facts > > "This rule matches all adv-attributes facts and binds their id and > attribute slots to variables" > > ;; Only use the $ prefix to match multifields in LHS patterns. Drop it > on the RHS of rules. > > ?fact <- (adv-attributes (id ?id) (attributes $?attribs)) > > => > > (printout t "Fact-id=" ?fact crlf) > > (printout t "id=" ?fact crlf) > > (printout t "attribs=" ?fact crlf)) > > > There a two things wrong, I think: > First is the line ?fact... there you call attributes and not attribs > Second are the printouts, how does JESS know, what the difference between > the three variable ?fact are? > I think you meant > > (printout t "Fact-id=" ?fact crlf) > > (printout t "id=" ?id crlf) > > (printout t "attribs=" ?attribs crlf)) > > > > Hope I'm right... not that good in programmer's stuff, just as good as in > english, sorry about that, but I try to get better. > > Lars H|bner > > > -------------------------------------------------------------------- > 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] > -------------------------------------------------------------------- > -------------------------------------------------------------------- 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] --------------------------------------------------------------------
