Search code examples
rulesrule-engineclips

Call one rule from another in clips


I wanted to know if there is any possibility of firing a rule from the RHS of another rule. for example,

rule 1:
(defrule printHello
=>
(printout t " Hello World" crlf ))

rule 2:
(defrule printName
=> 
/* tigger rule 1 */)

Solution

  • Expert systems are knowledge representation engines. They use knowledge (static and dynamic) to represent their internal state. In CLIPS, dynamic knowledge is represented with facts.

    You can use a custom dedicated fact for that.

    (defrule printHello
      (print hello)
    =>
      (printout t " Hello World" crlf))
    
    (defrule printName
    =>
      (assert (print hello)))