Clippy’s “Calendos” Program from 1988. I think it still works in QB64, but I haven’t tested it yet to be certain.
CALENDOS.BAS
'
' COMPUTER GENERATED CALENDER
'
' FILE records all holidays and weekends
' for accurate business days in year
'
DEFINT A-Z
'_FULLSCREEN 'QB64
DECLARE SUB GetDay (strday$, daynm%)
DECLARE SUB LeapYear (yr%, Lpy$, fday%)
DECLARE SUB Easter (yrn%, EM%, ED%)
OPTION BASE 1
DIM Day%(7, 6)
DIM Hol%(4)
DIM Rel%(4)
CLS
10
CLS
SCREEN 13
OUT &H3C8, 0 'assign color number 1 TO 15 in Screen 12
OUT &H3C9, 0 'red value
OUT &H3C9, 0 'green value
OUT &H3C9, 15 'blue value
SOUND 300, 4
'SOUND 700, 3 'Opening screen
COLOR 9
LOCATE 5, 13: PRINT "CALENDOS PROGRAM"
LOCATE 20, 3: PRINT "Year number or enter for present year:"
in$ = ""
DO: _LIMIT 100 'Get Input from User QB64
a$ = INKEY$
IF a$ <> "" AND a$ > CHR$(47) AND a$ < CHR$(58) THEN 'filter for numbers only
in$ = in$ + a$
ELSEIF a$ <> "" THEN EXIT DO
END IF
LOCATE 10, 15: PRINT "Year = "; in$
LOOP UNTIL LEN(in$) = 4
SLEEP 1
IF LEN(in$) = 4 THEN
Year$ = in$ 'Get year from user 4 digit
ELSE: Year$ = MID$(DATE$, 7, 4) 'get year from the actual date
END IF
yrn% = VAL(Year$) ' Check for number of year for leap year calculate
yrnum% = yrn% 'yrnum% is for adding year in second January and display
LeapYear yrn%, Lpy$, frstday%
Easter yrn%, EM%, ED%
num% = frstday% ' set first month 1st day position for calendar
37
'_______________READ NUM OF DAYS _____________ INKEY LOOP for months
FOR month% = 1 TO 13 'includes January of next year 13 months
ERASE Day%
fst% = num% 'get first day number(day) from num% for other months
SELECT CASE month% 'DAYS OF MONTH
CASE 2
IF Lpy$ = "N" THEN days% = 28
IF Lpy$ = "Y" THEN days% = 29
CASE 4, 6, 9, 11
days% = 30
CASE ELSE ' all other months have 31 days
days% = 31
END SELECT
week% = 1
FOR d% = 1 TO days% 'ASSIGN NUMBERS TO DAYS ARRAY
Day%(num%, week%) = d%
IF num% = 7 THEN
num% = 0
week% = 1 + week%
END IF
num% = 1 + num% 'SET NUMBER FOR NEXT MONTH
NEXT d%
'>>>>>>>>>>>>>>>>>>>>>>>> SELECT HOLIDAYS
ERASE Hol%, Rel% 'for each month
mond% = 0
tue% = 0
thu% = 0
'ADJUST FOR MONTHS WITHOUT DAY IN 1ST WEEK
IF Day%(2, 1) = 0 THEN mond% = 1
IF Day%(5, 1) = 0 THEN thu% = 1
IF Day%(3, 1) = 0 THEN tue% = 1
SELECT CASE month% 'holiday 2nd monday = Day%(2, 3)
CASE 1
mon$ = "JANUARY"
Hol%(1) = 1
Hol%(2) = Day%(2, 3 + mond%)
CASE 2
mon$ = "FEBRUARY"
Hol%(1) = Day%(2, 3 + mond%)
CASE 3
mon$ = "MARCH"
IF EM% = 3 THEN Rel%(1) = ED%
CASE 4
mon$ = "APRIL"
IF EM% = 4 THEN Rel%(1) = ED%
CASE 5
mon$ = "MAY"
Hol%(1) = Day%(2, 4 + mond%)
IF Day%(2, 5 + mond%) > 0 THEN Hol%(1) = Day%(2, 5 + mond%) 'last monday of month
CASE 6
mon$ = "JUNE"
CASE 7
mon$ = "JULY"
Hol%(1) = 4
CASE 8
mon$ = "AUGUST"
CASE 9
mon$ = "SEPTEMBER"
Hol%(1) = Day%(2, 1 + mond%)
CASE 10
mon$ = "OCTOBER"
Hol%(1) = Day%(2, 2 + mond%)
CASE 11
mon$ = "NOVEMBER"
Hol%(1) = Day%(3, 1 + tue%)
Hol%(2) = 11
Hol%(3) = Day%(5, 4 + thu%)
CASE 12
mon$ = "DECEMBER"
Hol%(1) = 25
CASE 13
mon$ = "JANUARY"
Hol%(1) = 1
Hol%(2) = Day%(2, 3 + mond%)
END SELECT
tomonth$ = MID$(DATE$, 1, 2) 'Get todays month in time line
IF MID$(tomonth$, 1, 1) = "0" THEN tomonth$ = MID$(DATE$, 2, 1)
SELECT CASE tomonth$ 'get month name
CASE "1": moon$ = "Jan."
CASE "2": moon$ = "Feb."
CASE "3": moon$ = "Mar."
CASE "4": moon$ = "Apr."
CASE "5": moon$ = "May "
CASE "6": moon$ = "June"
CASE "7": moon$ = "July"
CASE "8": moon$ = "Aug."
CASE "9": moon$ = "Sep."
CASE "10": moon$ = "Oct."
CASE "11": moon$ = "Nov."
CASE "12": moon$ = "Dec."
END SELECT
today$ = MID$(DATE$, 4, 2) 'Get todays date
yr$ = MID$(DATE$, 7, 4)
'Figure name of the day of week near clock using actual date
IF month% = 1 THEN
datenum% = VAL(today$) 'find date number
monthnum% = VAL(tomonth$) 'find month number
yrno% = VAL(yr$) ' find year number
LeapYear yrno%, Lp$, fstday% 'check if leap Get first day position number
mon1st% = fstday%
FOR i% = 1 TO monthnum% - 1
SELECT CASE i%
CASE 2
IF Lp$ = "N" THEN mon1st% = mon1st% + 28 'Feb
IF Lp$ = "Y" THEN mon1st% = mon1st% + 29
CASE 4, 6, 9, 11
mon1st% = mon1st% + 30 'April, June, Sept, Nov
CASE ELSE
mon1st% = mon1st% + 31 ' all others have 31 days
END SELECT
NEXT i%
IF Lp$ = "N" THEN lpno% = 365
IF Lp$ = "Y" THEN lpno% = 366
dayofyear% = mon1st% + datenum% - fstday%
IF Lp$ = "Y" AND dayofyear% >= 60 THEN dayofyear% = dayofyear% + 1
fstofmo% = mon1st% MOD 7 'finds day value of 1st day of month
daynum% = (datenum% + fstofmo% - 1) MOD 7 'finds value of actual day
SELECT CASE daynum% 'assign week day name
CASE 0: wd$ = "Sat"
CASE 1: wd$ = "Sun"
CASE 2: wd$ = "Mon"
CASE 3: wd$ = "Tue"
CASE 4: wd$ = "Wed"
CASE 5: wd$ = "Thu"
CASE 6: wd$ = "Fri"
END SELECT
END IF
COLOR 8
CLS
'*********************** PRINT CALENDER
COLOR 8
LOCATE 23, 7: PRINT "Any key for next month! "
IF month% = 13 THEN
SOUND 500, 3
'SOUND 700, 4
yrnum% = yrnum% + 1 ' add 1 for next year
LOCATE 23, 7: PRINT " Any key ends program! "
END IF
COLOR 13
LOCATE 2, 8: PRINT mon$
LOCATE 2, 24: PRINT yrnum%
COLOR 1
LOCATE 4, 8: PRINT "S M T W T F S "
COLOR 7
LOCATE 21, 7: PRINT "Day Num"; dayofyear%; " Left"; lpno% - dayofyear%
'LOCATE and PRINT day numbers............. from Day%() Array
FOR r% = 1 TO 6 'week loop r% begin
FOR c% = 1 TO 7 'day loop and colors
COLOR 14 'normal day color
IF c% = 1 OR c% = 7 THEN COLOR 5 'color weekends
FOR i% = 1 TO 3
IF Day%(c%, r%) = Hol%(i%) THEN COLOR 4 ' color holidays
IF Day%(c%, r%) = Rel%(i%) THEN COLOR 3 ' color Easter day
NEXT i%
LOCATE (2 * r%) + 4, (3 * c%) + 4: PRINT Day%(c%, r%)
IF Day%(c%, r%) = 0 THEN LOCATE (2 * r%) + 4, (3 * c%) + 4: PRINT SPACE$(2)
NEXT c%
NEXT r% 'r% week loop end
'**********************BOX around Calendar
COLOR 6
'LOCATE 3, 6: PRINT STRING$(23, CHR$(223))
LINE (48, 16)-(225, 20), 6, BF 'TOP
'LOCATE 17, 6: PRINT STRING$(23, CHR$(220))
LINE (48, 130)-(225, 134), 6, BF 'BOTTOM
LINE (44, 16)-(48, 134), 6, BF 'left side
LINE (225, 16)-(229, 134), 6, BF 'right side
'FOR i% = 3 TO 17
'LOCATE i%, 6: PRINT STRING$(1, CHR$(176)) 'Sides
'LOCATE i%, 29: PRINT STRING$(1, CHR$(176))
' NEXT i%
'*******************************
LOCATE 18, 20: COLOR 4: PRINT "Holidays"
IF month% = EM% THEN COLOR 3: LOCATE 18, 8: PRINT "Easter"
COLOR 9
LOCATE 20, 7: PRINT wd$; ", "; moon$; datenum%
DO: _LIMIT 1 'continuous time loop NEXT MONTH LOOP INKEY
hour$ = LEFT$(TIME$, 2)
SELECT CASE hour$
CASE "00"
hr$ = "12"
CASE "01", "13"
hr$ = " 1"
CASE "02", "14"
hr$ = " 2"
CASE "03", "15"
hr$ = " 3"
CASE "04", "16"
hr$ = " 4"
CASE "05", "17"
hr$ = " 5"
CASE "06", "18"
hr$ = " 6"
CASE "07", "19"
hr$ = " 7"
CASE "08", "20"
hr$ = " 8"
CASE "09", "21"
hr$ = " 9"
CASE "10", "22"
hr$ = "10"
CASE "11", "23"
hr$ = "11"
CASE "12", "24"
hr$ = "12"
END SELECT
IF hour$ < "12" THEN aft$ = " AM" 'set AM PM
IF hour$ >= "12" THEN aft$ = " PM"
minu$ = MID$(TIME$, 3, 3)
sec$ = RIGHT$(TIME$, 3) 'minutes & seconds
COLOR 9
LOCATE 20, 20: PRINT hr$; minu$;
COLOR 2
COLOR 9
PRINT aft$
LOOP UNTIL INKEY$ <> ""
NEXT month%
60 CLOSE #1
100 CLS
LOCATE 4, 4: PRINT " CALENDOS "
LOCATE 7, 4: PRINT " Written by Ted Weissgerber"
LOCATE 10, 4: PRINT " burger2227@Gmail.com"
LOCATE 14, 4: PRINT " 2010"
LOCATE 18, 4: PRINT " Qbasic and DOS Rule!"
SLEEP 3
SYSTEM
SUB Easter (yrn, EM, ED)
c = yrn \ 100 'Century
G = yrn MOD 19
K = (c - 17) \ 25
i = (c - (c \ 4) - (c - K) \ 3 + (19 * G) + 15) MOD 30
i = i - (i \ 28) * (1 - (i \ 28) * (29 \ (i + 1)) * ((21 - G) \ 11))
J = (yrn + yrn \ 4 + i + 2 - c + c \ 4) MOD 7
L = i - J
EM = 3 + (L + 40) \ 44 'Month of Easter.
ED = L + 28 - 31 * (EM \ 4) 'Day of Easter.
END SUB
SUB LeapYear (yrn%, Leap$, firstday%)
'my LEAP YEAR and the First Day of Year routine based on year 2000
LpYear% = 2000
firstday% = 7 ' the first day of 2000 was a saturday, the 7th day
IF yrn% >= 2000 THEN ' ** yrn% INPUT
'FORWARD LOOP 2000 up
yrnm% = 1999 'start in 1999
DO
yrnm% = yrnm% + 1 ' start in 2000 (1999 + 1)
IF yrnm% > 2000 THEN firstday% = firstday% + 1 'add one day every year to first day (52 weeks + 1
IF firstday% > 7 THEN firstday% = firstday% - 7 ' ** firstday% OUTPUT
IF yrnm% = LpYear% THEN Leap$ = "Y" ' ** Lp$ for print only
IF yrnm% MOD 100 = 0 THEN nly% = LpYear% MOD 400 'test century leap 400
IF nly% <> 0 THEN Leap$ = "N" ' if not divisible by 400
IF yrnm% - 1 = LpYear% THEN ' add day AFTER leap year
IF nly% = 0 THEN firstday% = firstday% + 1 ' add a leap day
IF firstday% > 7 THEN firstday% = firstday% - 7
Leap$ = "N"
LpYear% = LpYear% + 4 ' find next leap year by adding 4
END IF
nly% = 0 ' reset MOD value
LOOP UNTIL yrnm% = yrn%
END IF 'end forward loop
IF yrn% < 2000 THEN 'REVERSE LOOP 2000 down
yrnm% = 2001 'start in 2001
DO
yrnm% = yrnm% - 1 ' start in 2000 (2001 - 1)
IF yrnm% < 2000 THEN firstday% = firstday% - 1 'subt one day every year to first day (52 weeks + 1
IF firstday% = 0 THEN firstday% = 7
IF yrnm% MOD 100 = 0 THEN nly% = LpYear% MOD 400 ' test century every 100
Leap$ = "N"
IF yrnm% = LpYear% THEN ' BEFORE leap year
IF nly% = 0 AND LpYear% <> 2000 THEN firstday% = firstday% - 1 ' subt a leap day
IF firstday% = 0 THEN firstday% = 7
LpYear% = LpYear% - 4 ' find next leap year
Leap$ = "Y"
IF nly% <> 0 THEN Leap$ = "N" ' if not divisible by 400
END IF
nly% = 0 ' reset MOD value
LOOP UNTIL yrnm% = yrn%
END IF
END SUB