Can any one explain the code given below??... Its about the scheduling

Discussion in 'ASP' started by rag84dec, Apr 2, 2008.

  1. rag84dec

    rag84dec New Member

    Joined:
    Jul 17, 2007
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    <%@ LANGUAGE="VBScript" %>
    <% Option Explicit %>
    <%
    '+---------------------------------------------------+
    '| Scheduled Task in Active Server Pages             |
    '| Nick Sumner 06.2004                               |
    '| [url]http://www.tele-pro.co.uk/[/url]                        |
    '| [email]dev@nicksumner.com[/email]                                |
    '+---------------------------------------------------+
    '| asp_schedule_task.asp
    '| schedule a task in an ASP application
    '+---------------------------------------------------+
    
    
    'call AnyFunction() once every 6 hrs
    If (ScheduleTask("MyTaskName", "h", 6)) Then 
      Call AnyFunction()
    end If
    
    FUNCTION ScheduleTask(task_name, period, qty)
      Dim RunNow
      Dim last_date
      Dim diff
    
      'boolean result
      RunNow = False
    
      'chcek the value of app setting
      last_date = Trim(Application("Sched_" & task_name))
    
      'is value empty? maybe app just started
      If (last_date = "") Then
        RunNow = True
      Else
        'is value old?
        diff = DateDiff(period, last_date, Now())
        If (diff>=qty) Then RunNow = True
      End if
    
      'if scheduled to run now, set the app last run time
      If (RunNow) Then Application("Sched_" & task_name) = Now()
    
      'return result
      ScheduleTask = RunNow 
    END FUNCTION 
    
    %>
    
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice