2016-06-28 4 views
0

CLIPSでは、スロットの変更にイベントを関連付けることができるのだろうかと思います。 例:値の「窓-状態」の変更は、私が許可され、文字列に応じて、いくつかの関数を呼び出すしたいと思いますスロット変更時のイベント

(defclass ROOM (is-a USER) 
    (slot id 
     (type SYMBOL)) 
    (slot windows-status 
     (allowed-strings "open" "close"))) 

は、ありがとう ニコラ

答えて

1

使用前、後、またはスロットのput-方法についてのメッセージハンドラの周りに、あなたが値に基づいて、メッセージ・ハンドラから関数を呼び出すことができます。

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> 
関連する問題