home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / fileutil / sametime.arj / SAMETIME.PRG < prev   
Encoding:
Text File  |  1991-12-17  |  1.8 KB  |  76 lines

  1. *:*********************************************************************
  2. *:
  3. *:        Program: SAMETIME.PRG
  4. *:
  5. *:         System: Give a file the same time stamp as another
  6. *:         Author: John Wright
  7. *:
  8. *:  Procs & Fncts: FORCE_MAIN
  9. *:
  10. *:*********************************************************************
  11. * 12/17/91 - Created this program.
  12.  
  13. #INCLUDE date.hdr
  14. #INCLUDE jdfil.hdr
  15. #INCLUDE string.hdr
  16. #INCLUDE system.hdr
  17.  
  18. *!*********************************************************************
  19. *!
  20. *!      Procedure: FORCE_MAIN
  21. *!
  22. *!*********************************************************************
  23. PROCEDURE force_main
  24. PARAMETERS CHAR(127) cmd_line
  25.  
  26. VARDEF
  27.   CHAR      pattern
  28.   CHAR      _first_file
  29.   CHAR      _second_file
  30.   CHAR(8)   _file_date
  31.   CHAR(6)   _file_time
  32. ENDDEF
  33.  
  34. pattern = LTRIM(cmd_line)
  35.  
  36. IF pattern = "" .OR. "?" $ pattern
  37.   ?"Syntax:  SAMETIME <file>            Stamp file with current date & time"
  38.   ?"         SAMETIME <file> <file2>    Stamp file with date & time of file2"
  39.   ?""
  40.   QUIT
  41. ENDIF
  42.  
  43. * Set the variable to the current date and time.
  44. _file_date = DTOC(TODAY())
  45. IF SUBSTR(TIME(),1,2) < "12"
  46.    _file_time = SUBSTR(TIME(),1,5)+"a"
  47. ELSE
  48.    _file_time = SUBSTR(TIME(),1,5)+"p"
  49. ENDIF
  50.  
  51. IF " " $ pattern
  52.    _first_file  = SUBSTR(pattern,1,AT(" ",pattern)-1)
  53.    _second_file = SUBSTR(pattern,RAT(" ",pattern)+1,(LEN(pattern)-LEN(_first_file)+1))
  54.    IF EXIST(_second_file)
  55.       _file_date = Fgetdate(_second_file)
  56.       _file_time = Fgettime(_second_file)
  57.    ENDIF
  58. ELSE
  59.    _first_file  = pattern
  60. ENDIF
  61.  
  62. IF EXIST(_first_file)
  63.    ?"File: "+_first_file
  64.    Fsetdate(_first_file,_file_date)
  65.    ?"Date: "+_file_date
  66.    Fsettime(_first_file,_file_time)
  67.    ?"Time: "+_file_time
  68.    ?""
  69. ENDIF
  70.  
  71. QUIT
  72.  
  73. ENDPRO
  74.  
  75. *: EOF: SAMETIME.PRG
  76.