2011-03-29 72 views
3

我在全球塊以下:如何在KRL中設置謂詞?

test = defaction(){ 
    if(5>10) then { 
     notify("yes","yes");  
    } 
} 

然後我也有以下規則:

rule tester { 
    select when pageview ".*" 
    test(); 
} 

我期待的是,通知將永遠不會發生,因爲5決不會大於10.但是,它會在每一頁上運行。我確信我做錯了,儘管它感覺不錯。

回答

2

謂詞(如if (5>10) then不是動作塊的一部分。這樣,包括在defaction predicatees無厘頭你必須給它更多的是這樣寫的:。

global { 
    test = defaction(){ 
     notify("yes","yes");  
    } 
} 

rule tester { 
    select when pageview ".*" setting() 
    if (5>10) then { 
     test(); 
    } 
} 

if...then構造完成與every構造相同的功能:它包裝動作塊

+0

你是對的,條件必須放在瑕疵之外如果你想讓整齊的功能允許/或動作行爲,bug @pjw關於'非隨機選擇'。 – TelegramSam 2011-03-29 15:55:13