I read here how to call a python function on the lhs of a clips rule.
Now I have the following rule:
(defrule python_func_lhs "comment me"
(object (is-a clips_TEST_CLASS) (some_slot ?some_slot_value))
(test (eq (python-call python_print (str-cat "some_slot: " ?some_slot_value)) TRUE))
=>
;(assert (do_something))
)
My problem is that the python function is called twice, first printing
some_slot: nil
and then
some_slot: some_slot_value
It seems that the second rule part containing the python function does not "wait" for the first part of the LHS rule to be matched.
How can I make clips call the python function only one time, once the first part of the LHS rule is matched? In other words, I want to wait until the ?some_slot_value
variable has a value.
If possible I would like to avoid creating several rules and using "control facts".