home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Anwendungen / Kurztests / DFA / Rexx / ArexxScripts.lha / RemindBirthday.rexx < prev    next >
OS/2 REXX Batch file  |  1994-09-16  |  5KB  |  144 lines

  1. /************************************************************************/
  2. /*  CheckBirthdays.rexx                        by Frank Pecher          */
  3. /*                        changed for DFA V2.0 by Dirk Federlein        */
  4. /*                                                                      */
  5. /*                                                                      */
  6. /*  Check for birthdays in the next few days.                           */
  7. /*                                                                      */
  8. /*  SYNTAX                                                              */
  9. /*      CheckBirthdays                                                  */
  10. /*                                                                      */
  11. /*  FUNCTION                                                            */
  12. /*      This script checks all entries of the current DFA data file and */
  13. /*      examines the birthday-field, checking for birthdays in the next */
  14. /*      days. This way forgetting your friend's, parents', aunts' and   */
  15. /*      uncles' birthdays becomes very hard;-}.                         */
  16. /*                                                                      */
  17. /*          Put this in your Startup-Sequence, or create an IconX       */
  18. /*      project icon and put it into SYS:WBStartup, and you will be     */
  19. /*      reminded for pending birthdays everytime right after booting    */
  20. /*      your computer.                                                  */
  21. /*                                                                      */
  22. /*  REQUIREMENTS                                                        */
  23. /*      The date format in the birthday field must have one of the      */
  24. /*      following formats:                                              */
  25. /*          DD.MM.YYYY  like 13.08.1968                                 */
  26. /*          DD.MM.YY    like 13.08.68                                   */
  27. /*          DD.MM.      like 13.08.                                     */
  28. /*      In the first two cases, you will additionally be reminded       */
  29. /*      how old a person is going to be.                                */
  30. /*                                                                      */
  31. /*  CONFIGURATION                                                       */
  32. /*      To configure this script to your taste, edit the initialization */
  33. /*      of the two variables                                            */
  34. /*          DAYSBEFORE - the number of days you like to be reminded     */
  35. /*              before a birthday.                                      */
  36. /*          DAYSPASSED - the number of days you like to be reminded     */
  37. /*              after a birthday (good when coming home from holidays). */
  38. /************************************************************************/
  39. DAYSBEFORE  = 21
  40. DAYSPASSED  = 5
  41.  
  42.  
  43. /*************************************************************************
  44. **  main
  45. */
  46. if ~show(ports, DFA) then
  47. do
  48.     say "Start DFA first."
  49.     exit 0
  50. end
  51.  
  52. options RESULTS
  53.  
  54. /* Disable listview refresh of DFAEditor */
  55.  
  56. address "DFA" gui output off input off
  57.  
  58. address "DFA" first stem p.
  59.  
  60. today = date(i)
  61. thisyear = substr(date(s), 1, 4)
  62.  
  63. do while RC = 0
  64.     bday =  p.address.9
  65.  
  66.     if bday ~= "" then
  67.     do
  68.         birthday = ConvDate(p.address.9, thisyear)
  69.  
  70.         first = p.address.1
  71.         name  = p.address.2
  72.  
  73.         if birthday ~= 0 then
  74.         do
  75.             first = p.address.1
  76.             name  = p.address.2
  77.             diff = birthday - today
  78.  
  79.             if right(p.address.9, 1) = "." then
  80.             do
  81.                 howold = ""
  82.                 st     = ""
  83.             end
  84.             else
  85.             do
  86.                 howold = right(thisyear, 2) - right(p.address.9, 2)
  87.                 if howold < 0 then
  88.                     howold = howold + 100
  89.  
  90.                 howlast = right(howold, 1)
  91.  
  92.                 select
  93.                     when howlast = 1 then st = "st "
  94.                     when howlast = 2 then st = "nd "
  95.                     when howlast = 3 then st = "rd "
  96.                     otherwise             st = "th "
  97.                 end
  98.             end
  99.  
  100.  
  101.             if (diff = 1) | (diff = -1) then
  102.                 days = "day"
  103.             else
  104.                 days = "days"
  105.  
  106.             if (diff > 0) & (diff < DAYSBEFORE) then
  107.                 say "In "diff days" is "first name||x2c(27)"s "howold||st"birthday."
  108.             if (diff = 0) then
  109.                 say "*** Today is "first name||x2c(27)"s "howold||st"birthday. ***"
  110.             if (diff < 0) & (-diff < DAYSPASSED) then
  111.                 say diff * (-1) days" ago was "first name||x2c(27)"s "howold||st"birthday."
  112.         end
  113.     end
  114.  
  115.     address "DFA" next stem p.
  116. end
  117.  
  118. /* Enable listview refresh of DFAEditor */
  119.  
  120. address "DFA" gui output on input on
  121.  
  122. exit 0
  123.  
  124.  
  125. /******************************************************************************
  126. **  ConvDate()
  127. */
  128. ConvDate: procedure
  129.     arg bday,thisyear
  130.  
  131.     parse VAR bday day"."month"."year
  132.  
  133.     if length(day) < 2 then
  134.         day = 0||day
  135.  
  136.     if length(month) < 2 then
  137.         month = 0||month
  138.  
  139.     bd = thisyear||month||day
  140.  
  141.     return date(i, bd, s)
  142.  
  143.  
  144.