清除ent:变量在一定时间后过期

时间:2011-03-26 01:03:22

标签: krl

当用户第一次加载浏览器时,我正试图清除某些ent:变量。我从这个例子开始:

select using ".*" setting ()

if ent:browserOpened == 0 within 4 hours then {
    notify("Hello!", "Welcome to your browser! Kynetx rules doesn't it?)..... 
}
fired {
    ent:browserOpened += 1 from 1;
} else {
    ent:browserOpened += 1;
}

我的版本:

rule newWindow is active
  {
     //This rule checks to see if a persistent variable has been incremented in the 20 seconds
     select using ".*" setting ()

    if ent:browserOpened == 0 within 20 seconds then 
                 {                                                   
        popup(250, 250, 150, 400, "http://www.google.com")
       //noop();
           }
  fired 
         {
         ent:browserOpened += 1 from 1;  
         clear ent:clickMerchantID;                          
         }
    else 
         {    
         ent:browserOpened += 1;
         }                                  

  }

我怀疑它与我如何增加ent:browserOpened变量有关。如果我清除我的cookie并刷新浏览器,则弹出窗口仅会触发。我想它也可能是'内'动词。在文档中找不到太多关于它的内容。

当我知道规则正常启动时,我将删除弹出窗口并离开noop()。

感谢您的帮助!!

1 个答案:

答案 0 :(得分:3)

您可能发现了内部子句和计数器的错误。除了跟踪计数器,您还可以使用标志。我测试了以下内容并发现它可以工作:

rule newWindow {
   //This rule checks to see if a persistent variable has been incremented in the 20 seconds
   select using ".*" setting ()

  if not ent:browserOpened within 20 seconds then 
               {                                                   
      notify("test", "condition passed!");
     //noop();
         }
fired 
       {
       set ent:browserOpened;  
       clear ent:clickMerchantID;                          
       }
  else 
       {    
       set ent:browserOpened;
       }                                  

}

注意:

持久性变量的内部子句(以及标志的使用)显示在文档here

考虑使用notify()代替popup()进行测试,因为它更容易被识别,然后更好地观察alert()