我想知道在CLIPS中我是否可以将某个事件与插槽的修改相关联。 例如:
man 1 test
当' windows-status'值的变化,我想根据允许的字符串调用一些函数。
谢谢你, 尼古拉
答案 0 :(得分:1)
对插槽的put方法使用before,after或around消息处理程序,您可以根据值从消息处理程序中调用函数。
CLIPS> (clear)
CLIPS>
(defclass ROOM (is-a USER)
(slot id
(type SYMBOL))
(slot windows-status
(allowed-strings "open" "close")))
CLIPS>
(defmessage-handler ROOM put-id before (?value)
(printout t "put-id event " ?self:id crlf))
CLIPS>
(defmessage-handler ROOM put-windows-status before (?value)
(printout t "put-window-status event " ?self:windows-status crlf))
CLIPS> (make-instance [r1] of ROOM (id room1) (windows-status "open"))
put-id event nil
put-window-status event nil
[r1]
CLIPS> (send [r1] put-id room2)
put-id event room1
room2
CLIPS> (send [r1] put-windows-status "close")
put-window-status event open
"close"
CLIPS>