home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol155 / valdate.tst < prev    next >
Encoding:
Text File  |  1984-04-29  |  2.5 KB  |  89 lines

  1. * -----------------------------------------------------------------------------
  2. *            Program Name    : VALDATE.TST
  3. *            Author        : Keith R. Plossl
  4. *            Date Written    : January 1982
  5. * -----------------------------------------------------------------------------
  6. *  Program to Obtain and Validate the Date if System Date is Not Set
  7. *
  8. *  dBase II has date checking if it has been set already bypass
  9. *  everything else -- set OK to T and MM = 0 to bypass it all
  10. *
  11. if DATE() = '00/00/00'
  12.      store F   to OK
  13. else
  14.      store T   to OK
  15.      store 0   to MM
  16. endif
  17. do while .not. OK
  18. *
  19. *                   Initialize Loop Variables
  20. *
  21.      store $(BLNKS,1,8)            to DATE:VAR
  22.      store $(BLNKS,1,42)       to ERRX
  23. *
  24. *                   Get Date Input
  25. *
  26.      @ 18,15 say 'Enter Date as MM/DD/YY '
  27.      @ 18,43 get DATE:VAR  picture '##/##/##'
  28.      read
  29. *
  30. *                   Initialize Month, Day and Year Variables
  31. *
  32.      store val($(DATE:VAR,1,2))    to MM
  33.      store val($(DATE:VAR,4,2))    to DD
  34.      store val($(DATE:VAR,7,2))    to YY
  35. *
  36. *                   Date Validation Routine
  37. *
  38.      do case
  39. *
  40. *    If Month or Day exceeds 12 or 31 or is less than 1 or if 
  41. *    Year is less than 1980 then Error Results
  42. *
  43.           case MM<1 .or. MM>12 .or. DD<1 .or. DD>31 .or. YY<80
  44.                store '       Invalid Date - Reenter'   to ERRX
  45. *
  46. *     If the Month is Apr., Jun., Sep. or Nov. Test Number of
  47. *     days for over 30.  If over Set Error Message
  48. *
  49.           case MM=4 .or. MM=6 .or. MM=9 .or. MM=11 
  50.            if DD>30
  51.                store 'Thirty Days hath September, etc. - Reenter'   to ERRX
  52.            else
  53.             store T to OK
  54.            endif
  55. *
  56. *     If the Month is Feb. Check for Number of Days and Leap Year
  57. *     if not leap year and Days = 29 then Set Error Message
  58. *
  59.           case MM=2 .and. DD>28 .and. ((1900 + YY)/4)<>int(((1900 + YY)/4))
  60.                store '     Not a leap year - Try Again'   to ERRX
  61. *
  62. *    If the Month is Feb. and the Days exceed 29 Set Error Message
  63. *
  64.           case MM=2 .and. DD>29
  65.                store 'February has a Maximum of 29 Days - Reenter' to ERRX
  66. *
  67. *    If none of the above apply the date is OK - Set Flag and Loop out
  68. *
  69.           otherwise
  70.                @ 20,00
  71.                store T   to OK
  72.                loop
  73.      endcase
  74.      @ 20,00
  75.      @ 20,15 say ERRX
  76. enddo (.not. OK)
  77. *
  78. *    If Valid Date Was Entered at dBase II start Bypass Variable 
  79. *    release and Date Set.  Month is > Zero if not set at start.
  80. *
  81. if MM>0
  82.      release ERRX, OK, MM, DD, YY
  83.      set date to &DATE:VAR
  84.      clear gets
  85. endif
  86. return
  87. *
  88. *        End of Date Validation Program
  89. *