查看文章 |
asp时间触发器[8月13日修正]
2007年07月19日 星期四 10:40
大家应该注意到百度新闻和搜狗新闻等页面的右上角,会有类似这样的注明:“以下新闻由机器每5分钟自动选取更新”。其实这并不是一个神秘和高深莫测的功能,用ASP一样可以实现。 程序代码'=========================================================== '函数名称:ActivationSystem '功能描述:asp时间触发器 '作 者:GIDOT '参数说明:appname时间触发器名,keeptime触发过程的时限(单位:秒),subname所触发的过程。 '例 程:call ActivationSystem("Artlist",2000,"loadArtlist") '---------------------------------------------------------- sub ActivationSystem(appname,keeptime,subname) if Application(appname &"_dat") = "" then execute subname application(appname &"_dat") = now() else if datediff("s",Application(appname &"_dat"),now) >= keeptime then execute subname application(appname &"_dat") = now() end if end if end sub '=========================================================== 上面是我写的时间触发器,参数appname是为了实现同一网站可触发多个时间而给每个触发命名(任意命名,可使用中文),keeptime参数为每次触发的周期时间,subname为所触发的过程名。例子: call ActivationSystem("首页新闻",300,"printout") sub printout() '从数据库读取数据,并生成首页静态文件。 end sub 这么写,就实现了每间隔5分钟便自动更新一次首页的效果。 |
最近读者:
程序代码