i am new to clips rule engine and have to do following in clips in mobile app. if a person buys x amount of product A give him y discount.
Following is the code i have written to first check if my productid is in orders.
(deftemplate Producttemp
(slot productid (type INTEGER))
(slot umid)
(slot quantity (type INTEGER))
)
(deffacts orders
(Producttemp (productid 123) (umid CG) (quantity 4))
(Producttemp (productid 456) (umid CG) (quantity 2))
)
(defrule checkorder
=>
(printout t "Enter the productid: ")
(bind ?p1 (readline))
(printout t "Enter another quantity: ")
(bind ?p2 (readline))
(do-for-all-facts ((?o Producttemp))
(and (eq ?p1 ?o:p1)
(eq ?p2 ?o:p2))
(printout t ?p1 " is a " ?o: productid" in order " ?p2 crlf)))
)
I am getting following error.
Defining defrule: checkorder
[PRCCODE3] Undefined variable o: referenced in RHS of defrule.