home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / rexx / month.cmd < prev    next >
OS/2 REXX Batch file  |  1999-05-11  |  2KB  |  36 lines

  1. /******************************************************************************/
  2. /*  month                    Object REXX Samples                              */
  3. /*                                                                            */
  4. /*  Display the days of the month for January 1994                            */
  5. /*                                                                            */
  6. /*  This program is similar to the month1.cmd exec found in the OS/2 2.0      */
  7. /*  REXX User's Guide.  This version demonstrates the use of arrays to        */
  8. /*  replace stems.                                                            */
  9. /******************************************************************************/
  10.  
  11. /* First, create an array initialized to the days of the week                 */
  12. days = .array~of("Sunday",    "Monday",   "Tuesday", ,
  13.                  "Wednesday", "Thursday", "Friday",  ,
  14.                  "Saturday" )
  15. month = .array~new(31)                      /* Another way to create an array */
  16. startday = 7                                /* First day of month is Saturday */
  17.  
  18. Do dayofmonth = 1 to 31
  19.   dayofweek = (dayofmonth+startday+days~size-2) // days~size + 1
  20.   Select
  21.     When right(dayofmonth,1) = 1 & dayofmonth <> 11 then th = "st"
  22.     When right(dayofmonth,1) = 2 & dayofmonth <> 12 then th = "nd"
  23.     When right(dayofmonth,1) = 3 & dayofmonth <> 13 then th = "rd"
  24.     Otherwise th = "th"
  25.   end
  26.   /* Store text in the month array, using names in the days array             */
  27.   month[dayofmonth] = days[dayofweek] 'the' dayofmonth||th "of January"
  28. end
  29.  
  30. month~put( month[1]', New Years day', 1 )   /* Another way to set an array    */
  31.                                             /* element                        */
  32. Do dayofmonth = 1 to 31
  33.   Say month~at(dayofmonth)                  /* Another way to access array    */
  34.                                             /* elements                       */
  35. end
  36.