home *** CD-ROM | disk | FTP | other *** search
- /*
- @BCalendar @P@ICopyright Software Industry & General Hardware, September, 1993
-
- This Genie allows you to create a calendar of one Month including holidays.
- */
-
- /* TRACE RESULTS */
-
- if ~show(l, "gdarexxsupport.library") then
- if ~addlib("gdarexxsupport.library", 0, -30) then
- exit_msg("Please install the gdarexxsupport.library in your Libs: directory before running this Genie!")
- signal on error
- signal on syntax
-
- CALL AutoUpdate(0)
-
- DaysOfMonth.01 = 31; DaysOfMonth.05 = 31; DaysOfMonth.09 = 30;
- DaysOfMonth.02 = 28; DaysOfMonth.06 = 30; DaysOfMonth.10 = 31;
- DaysOfMonth.03 = 31; DaysOfMonth.07 = 31; DaysOfMonth.11 = 30;
- DaysOfMonth.04 = 30; DaysOfMonth.08 = 31; DaysOfMonth.12 = 31
-
- DayCount.Sun = 0; DayCount.Wed = 0; DayCount.Sat = 0
- DayCount.Mon = 0; DayCount.Thu = 0
- DayCount.Tue = 0; DayCount.Fri = 0
-
- TempString = LEFT( DATE( 'S' ), 4 )
- YearRequested = GetUserText( 16, "Enter the year [" TempString "]")
-
- IF ( YearRequested = "" ) | ( YearRequested = 0 ) THEN
- YearRequested = LEFT( DATE( 'S' ), 4 )
-
- LeapYear = YearRequested // 4
-
- if LeapYear = 0 then LeapYear = 1
-
- cr = '0a'x
-
- MonthList = ''
- do i = 1 to 12
- if i < 10 then MonthList = MonthList||'0'||i||cr
- else MonthList = MonthList||i||cr
- end
-
- Month = SelectFromList( "Please choose a month.", 30, 15, 0, MonthList )
-
-
- LastDayOfMonth = DaysOfMonth.Month
-
- if ( Month = 2 ) & ( LeapYear ) then LastDayOfMonth = 29
-
- DateOfInterest = YearRequested||Month||'01'
-
- DayOfWeek = Left(Date( 'W', DateOfInterest, 'S' ),3)
-
- NextPage = CurrentPage() + 2
-
- FilePath = GetFileName( "Where is Calendar page?", "PPage:", "BasicCalendar.ppp" )
-
- Success = LoadPage( NextPage, FilePath, 0 )
-
- if Success then do
- /* Get the holiday file */
- HolidayPath = GetFileName( "Where is Holiday info?", "REXX:", "Calendar.dat" )
- IF ( HolidayPath ~= "" ) & EXISTS( HolidayPath ) THEN DO
- IF Open( HP, HolidayPath, 'R' ) THEN DO
- /* At this point we have the file. */
-
- /* Skip all prior months to the month we are doing. */
- HolidayMonth = 0
- DO UNTIL ( ( HolidayMonth = Month ) | EOF( HP ) )
- Trash = Readln( HP )
- PARSE VAR Trash HolidayMonth Freq Description
- END
-
- HolidayCount = 0
-
- /* Get all this month's holidays. */
- DO WHILE ( ( HolidayMonth = Month ) & ( ~EOF( HP ) ) )
- HolidayCount = HolidayCount + 1
- HolidayFreq.HolidayCount = Freq
- HolidayInfo.HolidayCount = Description
- Trash = Readln( HP )
- PARSE VAR Trash HolidayMonth Freq Description
- END
- /* At this point all the holiday information has been read in */
- END
- END
-
- BoxId = SelectBox( 'MonthTitle' )
- BoxId = SetEdit( 'MonthTitle' )
- FontName = GetFont()
- CALL SetFont( "(CG)TIMES" )
- CALL SetJustification( 2 )
- FontSize = SetSize( 36 )
- CALL SetTracking( 85 )
- Success = InsertText( Date('M', DateOfInterest, 'S' ) YearRequested )
- CALL EndEdit()
-
- WeekCount = 1
- do Day = 1 to LastDayOfMonth
- if Day < 10 then NextBox = LEFT( DATE( 'W', YearRequested||Month||"0"||Day, 'S'),3)
- else NextBox = LEFT( DATE( 'W', YearRequested||Month||Day, 'S' ), 3 )
-
- DayCount.NextBox = VALUE( DayCount.NextBox ) + 1
-
- if ( NextBox == "Sun" ) & ( Day ~= 1 ) then WeekCount = WeekCount + 1
-
- Line.1 = "" /* output before number */
- Line.2 = "" /* output on 1st line after number */
- Line.3 = "" /* output on 2nd line after number */
-
- HolidaysThisDay = 0
- DO i = 1 TO HolidayCount
- /* checks for the form 1SUN */
- Temp = VALUE(DayCount.NextBox)
- Temp = Temp||NextBox
- IF LastDayOfMonth - Day + 1 < 8 THEN DO
- IF HolidayFreq.i = ( "L"||NextBox ) THEN DO
- HolidaysThisDay = VALUE( HolidaysThisDay ) + 1
- Line.HolidaysThisDay = HolidayInfo.i
- END
- END
- IF HolidayFreq.i = Temp THEN DO
- HolidaysThisDay = VALUE( HolidaysThisDay ) + 1
- Line.HolidaysThisDay = HolidayInfo.i
- END
- ELSE
- IF VALUE( HolidayFreq.i ) = Day THEN DO
- HolidaysThisDay = VALUE( HolidaysThisDay ) + 1
- Line.HolidaysThisDay = HolidayInfo.i
- END
- END i
-
- NextBox = NextBox||WeekCount
- BoxId = SelectBox( NextBox )
- BoxId = SetEdit( NextBox )
- CALL SetFont( "(CG)TIMES" )
- CALL SetTracking( 0 )
- /*
- Because the cursor is always at the first line of text we insert
- this text from bottom up.
- */
- FontSize = SetSize( 8 )
- CALL SetJustification( 2 ) /* Center justified */
- IF Line.3 ~= "" THEN Success = InsertText( cr||Line.3 )
- IF Line.2 ~= "" THEN Success = InsertText( cr||Line.2 )
-
- CALL SetJustification( 1 ) /* Right justified */
- FontSize = SetSize( 18 )
- Success = InsertText( Day )
-
- FontSize = SetSize( 8 )
- IF Line.1 ~= "" THEN Success = InsertText( Line.1||" " )
- CALL EndEdit()
- END
- END /* success on LoadPage */
-
- EXIT
-
- UserError:
- call ShowStatus( exit_msg )
- exit
-
- SYNTAX:
- call ShowStatus( "A syntax error at line" SIGL )
- exit
-
- ERROR:
- call ShowStatus( "An error at line" SIGL )
- exit
-