2013-12-21 19 views
0

我是CLIPS專家系統的新手。在CLIPS中終止指令

如何告訴CLIPS執行特定指令後停止執行規則???? !!

事端這樣的:

(defrule firstRule 
    (some assumption) 
    => 
    (if (X happened) then (and (print "yikes 1")(terminate the program)) 

(defrule secondRule 
    (some assumption) 
    => 
    (if (Y happened) then (and (print "yikes 2")(terminate the program)) 

(defrule thirdRule 
    (some assumption) 
    => 
    (if (Z happened) then (and (print "yikes 3")(terminate the program)) 

在該Y的情況下和Z發生,X沒有,我想是這樣的,以打印出:

yikes 2 

回答

2

使用此:

(if [condition] 
    then 
    (printout t "yikes 3" crlf) 
    (halt)) 

其中[condition]將會像變量,?b或表達式(> 3 4)一樣。在打印輸出語句中,t是指示輸出應該在哪裏的邏輯名稱(在這種情況下,t表示標準輸出),而crlf打印回車/換行(輸出的新行)。 (halt)語句在當前規則完成執行後停止執行規則。您可以通過在命令提示符下輸入(運行)來重新啓動執行。或者,(exit)命令將立即終止規則的執行以及CLIPS。