home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d7xx / d793 / datecheck.lha / DateCheck / DateCheck.rexx < prev    next >
OS/2 REXX Batch file  |  1993-01-10  |  2KB  |  63 lines

  1. /* DateCheck version 1.01 - Check the validity of the system date */
  2. /* Copyright © Michael Tanzer, 1992 */
  3. /* See additional notices in accompanying documentation */
  4.  
  5. datefile = 'S:DateCheck.date'     /* Identify file to contain stored date */
  6. maxdays = 1           /* Maximum days between stored date and system date */
  7.  
  8. /* Verify option or handle 'help' request */
  9. arg option
  10. if words(option)>0 & option~='RESET' then do
  11.   say 'Use DateCheck to check the validity of the system date.'
  12.   say 'Format: DATECHECK <RESET>'
  13.   say 'The ''RESET'' option forces the current system date to'
  14.   say 'be stored in' datefile 'without being checked.'
  15.   exit
  16.   end
  17.  
  18. /* Make sure the necessary libraries are available */
  19. if ~show('L','rexxsupport.library') then
  20.   call addlib('rexxsupport.library',0,-30)
  21. if ~show('L','rexxarplib.library') then
  22.   call addlib('rexxarplib.library',0,-30)
  23.  
  24. /* Handle RESET option */
  25. if option='RESET' then do
  26.   thisdate = date('B')
  27.   call write
  28.   exit
  29.   end
  30.  
  31. /* Compare current system date with stored date */
  32. call open('input',datefile,'R')
  33. if ~result then do
  34.   say 'Unable to open' datefile'.'
  35.   exit
  36.   end
  37. lastdate = readln('input')
  38. call close 'input'
  39. thisdate = date('B')
  40. if datatype(lastdate,'W') then difference = thisdate-lastdate
  41. else difference = -1
  42. if difference=0 then exit
  43. if difference<0 | difference>maxdays then do
  44.   parse value date() with day . year .
  45.   date = strip(day,'L','0') date('M') year
  46.   prompt = 'The system date appears to be' date'.'
  47.   response = request(0,0,prompt,,'No problem!','I had better fix that.')
  48.   if response~='OKAY' then exit
  49.   end
  50. call write
  51. exit
  52.  
  53. /* Store current system date */
  54. write:
  55.   call open('output',datefile,'W')
  56.   if ~result then do
  57.     say 'Unable to write' datefile'.'
  58.     exit
  59.     end
  60.   call writeln 'output',thisdate
  61.   call close 'output'
  62.   return
  63.