home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / calendar.pprx < prev    next >
Encoding:
Text File  |  1993-09-08  |  4.9 KB  |  171 lines

  1. /*
  2. @BCalendar  @P@ICopyright Software Industry & General Hardware, September, 1993
  3.  
  4. This Genie allows you to create a calendar of one Month including holidays.
  5. */
  6.  
  7. /* TRACE RESULTS */
  8.  
  9. if ~show(l, "gdarexxsupport.library") then
  10.    if ~addlib("gdarexxsupport.library", 0, -30) then
  11.       exit_msg("Please install the gdarexxsupport.library in your Libs: directory before running this Genie!")
  12. signal on error
  13. signal on syntax
  14.  
  15. CALL AutoUpdate(0)
  16.  
  17. DaysOfMonth.01 = 31; DaysOfMonth.05 = 31; DaysOfMonth.09 = 30;
  18. DaysOfMonth.02 = 28; DaysOfMonth.06 = 30; DaysOfMonth.10 = 31;
  19. DaysOfMonth.03 = 31; DaysOfMonth.07 = 31; DaysOfMonth.11 = 30;
  20. DaysOfMonth.04 = 30; DaysOfMonth.08 = 31; DaysOfMonth.12 = 31
  21.  
  22. DayCount.Sun = 0; DayCount.Wed = 0; DayCount.Sat = 0
  23. DayCount.Mon = 0; DayCount.Thu = 0
  24. DayCount.Tue = 0; DayCount.Fri = 0
  25.  
  26. TempString = LEFT( DATE( 'S' ), 4 )
  27. YearRequested = GetUserText( 16, "Enter the year [" TempString "]")
  28.  
  29. IF ( YearRequested = "" ) | ( YearRequested = 0 ) THEN
  30.   YearRequested = LEFT( DATE( 'S' ), 4 )
  31.  
  32. LeapYear = YearRequested // 4
  33.  
  34. if LeapYear = 0 then LeapYear = 1
  35.  
  36. cr = '0a'x
  37.  
  38. MonthList = ''
  39. do i = 1 to 12
  40.   if i < 10 then MonthList = MonthList||'0'||i||cr
  41.             else MonthList = MonthList||i||cr
  42. end
  43.  
  44. Month = SelectFromList( "Please choose a month.", 30, 15, 0, MonthList )
  45.  
  46.  
  47. LastDayOfMonth = DaysOfMonth.Month
  48.  
  49. if ( Month = 2 ) & ( LeapYear ) then LastDayOfMonth = 29
  50.  
  51. DateOfInterest = YearRequested||Month||'01'
  52.  
  53. DayOfWeek = Left(Date( 'W', DateOfInterest, 'S' ),3)
  54.  
  55. NextPage = CurrentPage() + 2
  56.  
  57. FilePath = GetFileName( "Where is Calendar page?", "PPage:", "BasicCalendar.ppp" )
  58.  
  59. Success = LoadPage( NextPage, FilePath, 0 )
  60.  
  61. if Success then do
  62.   /* Get the holiday file */
  63.   HolidayPath = GetFileName( "Where is Holiday info?", "REXX:", "Calendar.dat" )
  64.   IF ( HolidayPath ~= "" ) & EXISTS( HolidayPath ) THEN DO
  65.     IF Open( HP, HolidayPath, 'R' ) THEN DO
  66.       /* At this point we have the file. */
  67.  
  68.       /* Skip all prior months to the month we are doing. */
  69.       HolidayMonth = 0
  70.       DO UNTIL ( ( HolidayMonth = Month ) | EOF( HP ) )
  71.         Trash = Readln( HP )
  72.         PARSE VAR Trash HolidayMonth Freq Description
  73.       END
  74.  
  75.       HolidayCount = 0
  76.  
  77.       /* Get all this month's holidays. */
  78.       DO WHILE ( ( HolidayMonth = Month ) & ( ~EOF( HP ) ) )
  79.         HolidayCount = HolidayCount + 1
  80.         HolidayFreq.HolidayCount = Freq
  81.         HolidayInfo.HolidayCount = Description
  82.         Trash = Readln( HP )
  83.         PARSE VAR Trash HolidayMonth Freq Description
  84.       END
  85.       /* At this point all the holiday information has been read in */
  86.     END
  87.   END
  88.  
  89.   BoxId    = SelectBox( 'MonthTitle' )
  90.   BoxId    = SetEdit( 'MonthTitle' )
  91.    FontName = GetFont()
  92.    CALL SetFont( "(CG)TIMES" )
  93.    CALL SetJustification( 2 )
  94.    FontSize = SetSize( 36 )
  95.    CALL SetTracking( 85 )
  96.    Success = InsertText( Date('M', DateOfInterest, 'S' ) YearRequested )
  97.   CALL EndEdit()
  98.  
  99.  WeekCount = 1
  100.   do Day = 1 to LastDayOfMonth
  101.     if Day < 10 then NextBox = LEFT( DATE( 'W', YearRequested||Month||"0"||Day, 'S'),3)
  102.                 else NextBox = LEFT( DATE( 'W', YearRequested||Month||Day, 'S' ), 3 )
  103.  
  104.     DayCount.NextBox = VALUE( DayCount.NextBox ) + 1
  105.  
  106.     if ( NextBox == "Sun" ) & ( Day ~= 1 ) then WeekCount = WeekCount + 1
  107.  
  108.     Line.1 = "" /* output before number */
  109.     Line.2 = "" /* output on 1st line after number */
  110.     Line.3 = "" /* output on 2nd line after number */
  111.  
  112.     HolidaysThisDay = 0
  113.     DO i = 1 TO HolidayCount
  114.      /* checks for the form 1SUN */
  115.      Temp = VALUE(DayCount.NextBox)
  116.      Temp = Temp||NextBox
  117.      IF LastDayOfMonth - Day + 1 < 8 THEN DO
  118.        IF HolidayFreq.i = ( "L"||NextBox ) THEN DO
  119.          HolidaysThisDay = VALUE( HolidaysThisDay ) + 1
  120.          Line.HolidaysThisDay = HolidayInfo.i
  121.        END
  122.       END
  123.      IF HolidayFreq.i = Temp THEN DO
  124.        HolidaysThisDay = VALUE( HolidaysThisDay ) + 1
  125.        Line.HolidaysThisDay = HolidayInfo.i
  126.       END
  127.      ELSE
  128.        IF VALUE( HolidayFreq.i ) = Day THEN DO
  129.          HolidaysThisDay = VALUE( HolidaysThisDay ) + 1
  130.          Line.HolidaysThisDay = HolidayInfo.i
  131.        END
  132.     END i
  133.  
  134.     NextBox = NextBox||WeekCount
  135.     BoxId = SelectBox( NextBox )
  136.     BoxId = SetEdit( NextBox )
  137.       CALL SetFont( "(CG)TIMES" )
  138.       CALL SetTracking( 0 )
  139.       /*
  140.          Because the cursor is always at the first line of text we insert
  141.          this text from bottom up.
  142.       */
  143.       FontSize = SetSize(  8 )
  144.       CALL SetJustification( 2 ) /* Center justified */
  145.       IF Line.3 ~= "" THEN Success = InsertText( cr||Line.3 )
  146.       IF Line.2 ~= "" THEN Success = InsertText( cr||Line.2 )
  147.  
  148.       CALL SetJustification( 1 ) /* Right justified */
  149.       FontSize = SetSize( 18 )
  150.       Success  = InsertText( Day )
  151.  
  152.       FontSize = SetSize( 8 )
  153.       IF Line.1 ~= "" THEN Success = InsertText( Line.1||" " )
  154.     CALL EndEdit()
  155.   END
  156. END /* success on LoadPage */
  157.  
  158. EXIT
  159.  
  160. UserError:
  161.  call ShowStatus( exit_msg )
  162.  exit
  163.  
  164. SYNTAX:
  165.  call ShowStatus( "A syntax error at line" SIGL )
  166.  exit
  167.  
  168. ERROR:
  169.  call ShowStatus( "An error at line" SIGL )
  170.  exit
  171.