3

我正在尝试清除某些 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()。

谢谢你的帮助!!

4

1 回答 1

3

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

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;
       }                                  

}

笔记:

持久变量(以及标志的使用)上的 inside 子句显示在此处的文档中

考虑使用notify()而不是popup()用于测试,因为它更容易识别并且更好观察alert()

于 2011-03-26T04:02:01.437 回答