0
votes

when I try to call a defrule that have been used already, clips stop..

some defrule need to be used more than one time, is there any way to do it

here is an example

(

defrule choice-in-powerPlant2
(powerPlant2-question)
=>
(printout t "Are Filter and Carburetor Air working fine(y/n)?" crlf)
(bind ?response (check-YNoptions-input)); Get user input on type of questions
(if (eq ?response y)
    then
    (assert (powerPlant1-question)
    )
)

(if (or(eq ?response q) (eq ?response Q))
    then 
(output-exitmessage)

)

(if (eq ?response n)
    then
        (printout t "Have you fixed this(y/n)?" crlf)
        (bind ?response (check-YNoptions-input)); Get user input on type of questions
        (if (eq ?response y)
            then
            (assert (powerPlant1-question)
            )
        )
        (if (eq ?response n)
            then
            (printout req "Please replace Filter and Carburetor Air " crlf)
            (assert (powerPlant3-question))
    )
)
)

in rule 2 I want to go back to rule 1 when I enter "y"=yes

" running stopped once I enterd "y" "

1

1 Answers

0
votes

If you want to retrigger a rule that matches a specific fact, retract that fact as part of the rule action. If another rule then asserts that specific fact, the rule will be retriggered. For example:

(defrule choice-in-powerPlant2
   ?f <- (powerPlant2-question)
   =>
   (retract ?f)
   (printout t "Are Filter and Carburetor Air working fine(y/n)?" crlf)
      .
      .
      .
)