home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / ibm1 / ralphson.arj / DATEUTLS / DATEWARN.DOC < prev    next >
Encoding:
Text File  |  1991-11-17  |  3.4 KB  |  140 lines

  1.  
  2.        DATEWARN.DOC - Documentation for DateWarn version 1.04  17/11/1991
  3.  
  4.     Documentation and executable code Copyright (c) 1991 Michael E. Ralphson
  5.  
  6.  
  7. Disclaimer:
  8. ===========
  9.  
  10. The Author retains copyright in that he alone has the right to make copies for
  11. profit. In all other respects users may treat this software as if it were in
  12. the Public Domain, as long as the package is distributed whole and unmodified.
  13.  
  14. In my opinion this software is perfectly safe and is free of any serious bugs,
  15. however I have to make it clear that use of this software constitutes the
  16. user's full acknowledgement that the author takes no responsibility WHATSOEVER
  17. for the consequences of such use.
  18.  
  19. Commercial users must register within 30 days if they wish to continue using
  20. this software. For non-commercial users registration is purely voluntary. See
  21. enclosed Register.Txt for more details.
  22.  
  23.  
  24. Introduction:
  25. =============
  26.  
  27. DateWarn is a simple program that works out how old a specified file is in
  28. days and compares this to a user-specified value. DateWarn displays on screen
  29. the age of the specified file in days and if this is greater or equal to the
  30. number of days specified on the command-line it halts with a DOS ErrorLevel of
  31. 1 (which can be tested for in a batch file). If the file could not be found,
  32. DateWarn exits with an ErrorLevel of 2, in all other circumstances DateWarn
  33. exits with an ErrorLevel of 0.
  34.  
  35.  
  36. Usage:
  37. ======
  38.  
  39. DateWarn <file to check> <number of days>
  40.  
  41. If, for example, DateWarn was run with the following command-line:
  42.  
  43. DateWarn lastback.up 14
  44.  
  45. Assume that the file LASTBACK.UP was created on the 3rd of February 1991 and
  46. the program is run on the 17th of February 1991.
  47.  
  48. The output from DateWarn is:
  49.  
  50. C:\LASTBACK.UP is dated 14 days ago.
  51.  
  52. And then the program exits with an ErrorLevel of 1 to show that the condition
  53. was satisfied.
  54.  
  55.  
  56. A Practical Example:
  57. ====================
  58.  
  59. Consider this example AUTOEXEC.BAT:
  60.  
  61. @ECHO OFF
  62.  
  63. REM Run all the normal start-up programs
  64.  
  65. PROMPT $P$G
  66. PATH C:\;C:\DOS;C:\BAT;
  67. KEYB UK
  68.  
  69. REM Make sure battery backed clock has not reset.
  70.  
  71. 1980TEST
  72. IF ERRORLEVEL 1 GOTO NEWDATE
  73.  
  74. :RETURN
  75.  
  76. REM Was the last backup more than a week ago?
  77.  
  78. DATEWARN LASTBACK.UP 7
  79. IF ERRORLEVEL 2 GOTO BACKUP-F
  80. IF ERRORLEVEL 1 GOTO BACKUP-I
  81. GOTO END
  82.  
  83. :NEWDATE
  84.  
  85. DATE
  86. TIME
  87. GOTO RETURN
  88.  
  89. :BACKUP-F
  90.  
  91. REM Run full backup
  92.  
  93. CD\BACKUP
  94. BACKUP /F
  95. CD\
  96. GOTO UPDATE
  97.  
  98. :BACKUP-I
  99.  
  100. REM Run back-up software in incremental mode.
  101.  
  102. CD\BACKUP
  103. BACKUP /I
  104. CD\
  105.  
  106. :UPDATE
  107.  
  108. REM Create a new file LASTBACK.UP with today's date
  109.  
  110. ECHO This file is used by DateWarn.Exe>LASTBACK.UP
  111.  
  112. :END
  113.  
  114.  
  115. The important parts to note are:
  116.  
  117. 1) The test for the ErrorLevel is performed IMMEDIATELY after DateWarn is run.
  118.  
  119. 2) The Backup section of the batch file creates a new LASTBACK.UP file, thus
  120.    ensuring it has today's date. If your backup software creates or updates a
  121.    file every time it is run, you can use this instead of LASTBACK.UP and
  122.    remove the ECHO ... >LASTBACK.UP line.
  123.  
  124. 3) The user is asked to enter the date if the battery backed clock resets (most
  125.    reset to 1st January 1980) because of battery failure. 1980TEST.COM is
  126.    included in this archive.
  127.  
  128.  
  129. Version History:
  130. ================
  131.  
  132.  1.03  -  May 91 Initial version
  133.  1.04  -  Nov 91 ErrorLevel dropped if file doesn't exist
  134.  
  135.  
  136. Thanks To:
  137. ==========
  138.  
  139. Edward Devlin and Mark Cracknell.
  140.