Part II
Add Program Functionality
Add date functions
I added a few date functions that will be used to calculate
any selected day, month, or year. Several of these functions came from the XB
mailing list (thanks). I added:
DateToGregorianDayNumber ( )
Gregorian ( )
Julian ( )
Weekday ( )
Create SUBs in CalendarCode ( )
The next step involves adding all of the data and
event processing subroutines. I have added SUBs that will do calculations to
get the current day, then display the proper dates in each of the day kid grids.
Then I added code to change the day and month using the arrow PressButtons.
And finally, I wanted to highlight the currently selected day when it is clicked
by the left mouse button.
Changes to SUB Selection
It might of interest to point out how I compressed the SUB
Selection subroutine. Our code generated by the Toolkit creates a selection
for EACH kid grid in our program. So we had 58 kids in our SELECT
CASE statement. I changed the SELECT CASE kid to SELECT CASE
TRUE and changed the CASE statements as follows:
SELECT CASE TRUE
CASE kid = $MonthLeftArrowPressB : DEC month
IF month = 0 THEN
month = 12
DEC year
END IF
CASE kid = $MonthRightArrowPressB : INC month
IF month > 12 THEN
month = 1
INC year
END IF
CASE kid = $YearLeftArrowPressB : DEC year
CASE kid = $YearRightArrowPressB : INC year
CASE kid >= $Day1
: GOSUB DaySelection
EXIT SUB
END SELECT
Our calendar grid looks basically the same as in Part I, but now it works and the currently selected day is highlighted in yellow.

It is not the intent of this discussion to go over the code in this part and so I will leave it to the reader to go through the code in CalendarCode ( ) on their own. The code for this section of Part II can be found in calendar1.x.
Continue Adding new functionality to CalendarCode ( )
At this point there are few things that I needed to add or
correct. First, I wanted to grey out the days shown in the calendar that where
not part of the current month. Next, I had to add code to update the labels
so that they reflected the currently selected date.
Then things started to get a bit tricky. I wanted to be able to select a day that was not in the current month. This would change the calendar to the next or previous month, highlight the selected day, and update all the labels.
Another item that needed work involved selecting months or years. In order to keep accurate track of the day grid selection, I decided that all changes to the year or month by the arrow PressButtons would set the current day to the 1st of the month.

And finally, I added the Today PushButton in order to make it easy to return to the current day. Here is what the next version looks like. The code for this version is in calendar2.x.
In the Next Part
(c) 2000 David SZAFRANSKI