home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / wnote192.zip / birthday.cmd next >
OS/2 REXX Batch file  |  2000-05-03  |  5KB  |  137 lines

  1. /**************************************************************************/
  2. /*                                                                        */
  3. /* BIRTHDAY.CMD   Example program to demonstrate the use of WarpNote in   */
  4. /*                connection with WarpNote Command. This program scans    */
  5. /*                the file BIRTHDAY.TXT for coming anniversaries and if   */
  6. /*                there are such events, the program creates a note to    */
  7. /*                inform the user. This program could be run in your      */
  8. /*                Startup folder. You may and you should customize this   */
  9. /*                program for your own needs.                             */
  10. /*                                                                        */
  11. /* Created on November 8th, 1997, Uwe Schlenther, 70193 Stuttgart,Germany */
  12. /**************************************************************************/
  13.  
  14. NoteNumber=100     /* This is the number of the note we will create. Make */
  15.                    /* sure that you don't use this number for your own    */
  16.                    /* needs and change it if necessary.                   */
  17.  
  18. Days=14            /* This is the number of days we will watch for coming */
  19.                    /* events, counting from today.                        */
  20.  
  21. InFile="BIRTHDAY.TXT"   /* This is the file containing the birthday data. */
  22.  
  23. OutFile="NEWNOTE"
  24.  
  25. "del "OutFile
  26.  
  27. "wncomm wait"                               /* Wait for WarpNote startup. */
  28. "wncomm delete "NoteNumber     /* Delete a previous instance of the note. */
  29.  
  30. call LINEOUT OutFile,"Coming Anniversaries",1
  31. call LINEOUT OutFile,"===================="
  32. call LINEOUT OutFile,""
  33.  
  34. call SetMonthDays
  35.  
  36. NumAnniversaries=0
  37.  
  38. Today=DATE("S")
  39. parse var Today Year 5 Month 7 Day
  40.  
  41. do i=0 to Days
  42.   call ScanBirthdayFile Day,Month,Year
  43.   NumAnniversaries=NumAnniversaries+result
  44.  
  45.   Day=Day+1
  46.   if Day>MonthDays.Month then do
  47.     Day=1
  48.     Month=Month+1
  49.   end
  50.   if (Month=2) & (Day=29) & (Year//4<>0) then do /* Simple algorithm for */
  51.     Day=1                                        /* leap year. Should    */
  52.     Month=Month+1                                /* suffice for this     */
  53.   end                                            /* purpose.             */
  54.   if Month>12 then do
  55.     Month=1
  56.     Year=Year+1
  57.   end
  58. end
  59.  
  60. LINEIN(OutFile,1,0)       /* Reset file pointer on anniversary data file. */
  61.  
  62. /* If anniversaries have been written to the OutFile, create a note.    */
  63.  
  64. if (NumAnniversaries>0) then do
  65.   "wncomm getdesktopx"                  /* Get horizontal desktop size. */
  66.   DesktopX=rc
  67.   "wncomm getdesktopy"                    /* Get vertical desktop size. */
  68.   DesktopY=rc
  69.   "wncomm create "NoteNumber                        /* Create the note. */
  70.   "wncomm setsizexy "NoteNumber DesktopX%2 DesktopY%4
  71.   "wncomm center "NoteNumber
  72.   "wncomm load "NoteNumber" newnote"
  73.   "wncomm show "NoteNumber
  74. end
  75.  
  76. exit
  77.  
  78. ScanBirthdayFile:
  79.   arg Day,Month,Year
  80.  
  81.   Count=0
  82.  
  83.   LINEIN(InFile,1,0)      /* Reset file pointer on anniversary data file. */
  84.  
  85.   do while LINES(InFile)               /* Look through all lines of data. */
  86.     Line=LINEIN(InFile)
  87.     if (SUBSTR(Line,1,1)<>":") & (Line<>"") then do
  88.       parse var Line ADay "," AMonth "," AYear "," AName   /* Parse line. */
  89.       if (ADay=Day) & (AMonth=Month) then
  90.       do
  91.         Count=Count+1          /* Increase number of found anniversaries. */
  92.         MName=MonthName(AMonth)
  93.         Line=ADay MName": "AName
  94.         if (AYear<>"") then do    /* Add age if yearappears in data file. */
  95.           Age=Year-AYear
  96.           Line=Line "("Age")"
  97.         end
  98.         call LINEOUT OutFile,Line
  99.       end
  100.     end
  101.   end
  102. return Count
  103.  
  104. MonthName:
  105.   arg MonthNumber
  106.  
  107.   select
  108.     when MonthNumber=1 then return "January"
  109.     when MonthNumber=2 then return "February"
  110.     when MonthNumber=3 then return "March"
  111.     when MonthNumber=4 then return "April"
  112.     when MonthNumber=5 then return "May"
  113.     when MonthNumber=6 then return "June"
  114.     when MonthNumber=7 then return "July"
  115.     when MonthNumber=8 then return "August"
  116.     when MonthNumber=9 then return "September"
  117.     when MonthNumber=10 then return "October"
  118.     when MonthNumber=11 then return "November"
  119.     when MonthNumber=12 then return "December"
  120.   end
  121. return 0
  122.  
  123. SetMonthDays:
  124.   MonthDays.1=31
  125.   MonthDays.2=29
  126.   MonthDays.3=31
  127.   MonthDays.4=30
  128.   MonthDays.5=31
  129.   MonthDays.6=30
  130.   MonthDays.7=31
  131.   MonthDays.8=31
  132.   MonthDays.9=30
  133.   MonthDays.10=31
  134.   MonthDays.11=30
  135.   MonthDays.12=31
  136. return 0
  137.