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分钟便自动更新一次首页的效果。
posted @ 2008-06-15 18:00  Tony_YANG  阅读(373)  评论(0编辑  收藏  举报