news
About Elegant Chaos
info
About me and my friends
people
Software from Elegant Chaos
software
Other stuff...
stuff

DL_UpdateMe

Revision
Revised on

Description


Code

on DL_UpdateMe
  global DL_HeaderTemplate, DL_DoChecks
  
  if (DL_DoChecks is true) then
    put the script of the target into scr
    if scr is empty then exit DL_UpdateMe
    put the number of lines in scr into scriptSize
    put false into timeToUpdate
    
    if not DL_HasHeader(scr) then
      set cursor to watch
      UL_StartProgress "Documenting script",5
      UL_AdvanceProgress "Inserting header"
      put DL_HeaderTemplate before scr
      put true into timeToUpdate
    else
      put DL_TimeToUpdate(scr,scriptSize) into timeToUpdate
      if timeToUpdate then
        UL_StartProgress "Documenting script:" & DL_GetScriptField("Name",scr),4
      end if
    end if
    
    if timeToUpdate then
      set cursor to watch
      UL_AdvanceProgress "Updating revision"
      put DL_GetScriptField("Revision",scr) into revision
      put item 1 of revision into version
      put (version + 1) & ", " & the date && the time into revision
      put DL_SetScriptField("Revision",scr,revision) into scr
      put DL_SetScriptField("Lines",scr,the number of lines in scr) into scr
      put DL_UpdateLists(scr) into scr
      
      set the script of the target to scr
      UL_FinishProgress
      return "updated"
    end if
  end if
  
end DL_UpdateMe