dang I searched for my calendar post, nothing??? I know Ken and I interacted on calendars years ago but where?
Here is a calendar maker < 210 LOC for printing up on paper to write on appointments... it's set for 2026 starting Feb as I printup calendars for family members at Christmas ( I didn't update Title or comments for current year just data. ) and goes thru next January 2027, so family can write in appointments for January before they get next years calendar.
The B-days are just personal family birthdays you can comment out but see how easy they are to add to the code:
This is nice demo how to print out your own form also!
Note: this February was the first calendar I ever printed out that only needed 4 Rows for weeks, 28 days started exactly on Sunday. Totally unexpected and it leaves out the Month and year label at the top. A fluke! not likely to happen again for years!
Comment #2: this code works fine for a Canon printer that uses toner! And I have to say a Toner printer instead of a Ink printer is a million times less frustrating NOT having to deal with dried up ink problems!!! I recommend highly unless you print out photos and use printer more than a couple times a year.
Here is a calendar maker < 210 LOC for printing up on paper to write on appointments... it's set for 2026 starting Feb as I printup calendars for family members at Christmas ( I didn't update Title or comments for current year just data. ) and goes thru next January 2027, so family can write in appointments for January before they get next years calendar.
The B-days are just personal family birthdays you can comment out but see how easy they are to add to the code:
Code: (Select All)
_Title "Calendar Remake 2024-11-02 for 2025" 'B+ 2018-12-08 from SmallBASIC old FLTK files (PalmOS version)
' This program creates 5 or 6 row calendars (Sun thru Sat) depending upon needs of month.
' You will see the preview on the screen.
' I used _MAPTRIANGLE to put the calendar in landscape view so will print on normal
' typewriter sheet: 8.5 X 11 USA measure with Windows 10 and HP envy 5530 printer.
'2019-09-11 pretty close to fixed up for Christmas
' add leapyear, and Easter calc subs
' add Holidays helped by Ken's Calendar Maker
'2020-08-21 make 2021 Calendars now while I have new Black Ink Cartridge
' make a list of items I need dates for marked with ............. year only
' 2021-10-24 This program fixed for Font fixes since QB64 v1.4 but naming is terrible Why FH?
' 2022-11-02 get calendars ready for next year
' >>>>>>>>>>>>> see Canon Printer Advice.txt for reminder how to use printer
' 2023-11-05 Where is that list of things to get info/dates for?
' see ' date look for <<<<<<<<<< and ..................
Const XMAX = 1100
Const YMAX = 700
Const tMar = 40 'top margin allows room for 3 hole binder punch on top
' (landscape orientation) or left side (portrait orientation)
Const sideMar = 10
Screen _NewImage(XMAX, YMAX, 32)
_ScreenMove 100, 0
Dim dayNames$(0 To 6), monthNames$(1 To 12), monthDays(1 To 12) As Integer
For i = 0 To 6: Read dayNames$(i): Next
Data "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
For i = 1 To 12: Read monthNames$(i): Next
' split line to fit screen
Data "January","February","March","April","May","June","July","August","September"
Data "October","November","December"
For i = 1 To 12: Read monthDays(i): Next
Data 31,28,31,30,31,30,31,31,30,31,30,31
' this loads and checks fonts (Windows 10)
Dim Shared FH, CH, CW, FH2, CH2, CW2
FH = _LoadFont("ARLRDBD.TTF", 24)
If FH <= 0 Then Print "Trouble with font load file, goodbye.": Sleep: End
CH = _FontHeight(FH): CW = CH * .6
'this make printing char by char the same as printing a string for ARLRDBD.ttf
_Font FH
'test font, in box? for 5 above 5 below height = 30
'Line (5, 5)-Step(CW * Len(monthNames$(1) + Str$(2018)), 30), , B
'_PrintString (10, 10), monthNames$(1) + Str$(2018)
FH2 = _LoadFont("ARLRDBD.TTF", 18) ' I had to load this in folder?!?!
If FH2 <= 0 Then Print "Trouble with font load file, goodbye.": Sleep: End
CH2 = _FontHeight(FH2): CW2 = CH2 * .5
'this make printing char by char the same as printing a string for ARLRDBD.ttf
_Font FH2
'Line (5, 45)-Step(CW2 * Len("testing smaller font 1, 2, 3, 31"), 25), , B
'_PrintString (10, 50), "testing smaller font 1, 2, 3, 31"
y = 2026 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< update for 2025
Dim EasterMonth As Integer, EasterDay As Integer
Easter y, EasterMonth, EasterDay
'Print EasterMonth, EasterDay, CH2 ' check Easter
'End
For mm = 2 To 13
If mm = 13 Then m = 1: y = y + 1 Else m = mm
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
Cls
'day month starts, probably the most crucial formula from the SmallBASIC program
d = (1461 * (y + 4800 + (m - 14) \ 12) \ 4 + 367 * (m - 2 - 12 * ((m - 14) \ 12)) \ 12 - 3 * ((y + 4900 + (m - 14) \ 12) \ 100) \ 4 + 1) Mod 7
' fix leap year for true = -1
monthDays(2) = 28 + leapYear(y)
'from these calcs for month year determine amount of rows calendar will need
rows = (monthDays(m) + d + 6) \ 7
boxW = Int((XMAX - 2 * sideMar) / 7)
monthYear$ = monthNames$(m) + Str$(y)
_Font FH2
If rows = 5 Then
yTitle = tMar + 5
yDayNames = tMar + 40 'strings line above is -5 and line below is yTopGrid
yTopGrid = yDayNames + 20
boxH = Int((YMAX - yTopGrid - sideMar) \ rows)
yBottomGrid = yTopGrid + rows * boxH
'center monthYear$ at top
_Font FH
_PrintString ((XMAX - Len(monthYear$) * CW) / 2, yTitle), monthYear$
_Font FH2
Else
yDayNames = tMar + 5 ' for day name strings, line above is -5 and line below is yTopGrid
yTopGrid = yDayNames + 20
boxH = Int((YMAX - yTopGrid - sideMar) \ rows)
yBottomGrid = yTopGrid + rows * boxH
yTitle = yTopGrid + .5 * boxH - 10
' print month year title after the rest of the calendar is done
End If
Line (sideMar, yDayNames - 5)-Step(7 * boxW, 1), , BF
'verticals and daytitles
For day = 0 To 7
x = sideMar + day * boxW
Line (x, yDayNames - 5)-(x + 1, yBottomGrid), , BF
If day < 7 Then
xoff = (boxW - Len(dayNames$(day)) * CW2) / 2
_PrintString (x + xoff, yDayNames), dayNames$(day)
End If
Next
Line (sideMar, yTopGrid)-Step(7 * boxW, 1), , BF
' horizontals
For n = 1 To rows
Line (sideMar, yTopGrid + boxH * n)-Step(7 * boxW, 1), , BF
Next
' dates
For i = 0 To monthDays(m) - 1
dd = i + 1
row = (d + i) \ 7
col = (d + i) Mod 7 ' 0 is Sunday, 1 is Monday
weekday = col + 1 Mod 7 'so my monday 1 matches ken's 2
S$ = LTrim$(Str$(i + 1))
'insert hoidays to add to square >>>>>>>>>>>>>>>>>>>>>>>>> BE CAREFUL a B-Day falls on another Day
If m = 1 And dd = 1 Then S$ = S$ + " New Years"
If m = 1 And weekday = 2 And dd > 14 And dd < 22 Then S$ = S$ + " MLK Jr."
If m = 2 And dd = 2 Then S$ = S$ + " Groundhog"
If m = 2 And weekday = 2 And dd > 14 And dd < 22 Then S$ = S$ + " Presidents"
If m = 2 And dd = 14 Then S$ = S$ + " Valentines"
If m = 3 And dd = 8 Then S$ = S$ + " DLS" '......................... DayLight Savings check yearly
If m = 3 And dd = 13 Then S$ = S$ + " Mark B-day" ' ...... in 2022 this lands on same day as DayLight
If m = 3 And dd = 17 Then S$ = S$ + " St. Patrick"
If m = 3 And dd = 29 Then S$ = S$ + " Betsy B-day"
If m = 4 And dd = 24 Then S$ = S$ + " Arbor" '.................. this changed 2025
If m = 5 And dd = 5 Then S$ = S$ + " Election" ' ................. check yearly
If m = 5 And dd = 6 Then S$ = S$ + " Tim B-day"
If m = 5 And weekday = 1 And dd > 7 And dd < 15 Then S$ = S$ + " Mother's Day"
If m = 5 And weekday = 0 And dd > 14 And dd < 22 Then S$ = S$ + " Armed Forces"
If m = 5 And weekday = 2 And dd > 24 Then S$ = S$ + " Memorial"
If m = 6 And dd = 14 Then S$ = S$ + " Flag"
If m = 6 And weekday = 1 And dd > 14 And dd < 22 Then S$ = S$ + " Father's Day"
If m = 7 And dd = 4 Then S$ = S$ + " Independence"
If m = 8 And dd = 19 Then S$ = S$ + " Butch B-day"
If m = 9 And weekday = 2 And dd < 8 Then S$ = S$ + " Labor"
If m = 9 And dd = 30 Then S$ = S$ + " Debbie B-day"
If m = 10 And dd > 9 And dd < 16 And weekday = 2 Then S$ = S$ + " Columbus"
If m = 10 And dd = 31 Then S$ = S$ + " Halloween"
If m = 11 And dd = 1 Then S$ = S$ + " End Daylight" '........................... check yearly
If m = 11 And dd = 3 Then S$ = S$ + " Election Day" '........................... check yearly
If m = 11 And dd = 11 Then S$ = S$ + " Veterans"
If m = 11 And dd = 19 Then S$ = S$ + " Cory B-day"
If m = 11 And dd > 21 And dd < 29 And weekday = 5 Then S$ = S$ + " Thanksgiving"
If m = 12 And dd = 25 Then S$ = S$ + " Christmas"
If m = EasterMonth And dd = EasterDay Then S$ = S$ + " Easter" '.... might fall on BDay check yearly
'If m = EasterMonth And dd = EasterDay Then 'mom's bday falls on Easter in 2020
' _PrintString (col * boxW + sideMar + 5, (row + 1) * boxH + yTopGrid - 5 - CH2), " Easter"
'End If
_PrintString (col * boxW + sideMar + 5, row * boxH + yTopGrid + 5), S$
Next
If rows = 6 Then 'insert month name in top row about 200 in?
'first clear lines in first 4 blocks
Line (sideMar + 2, yTopGrid + 2)-Step(4 * boxW - 4, boxH - 3), _RGB32(255, 255, 255), BF
'center monthYear$ in first 4 blocks (never used in 6 row calendar)
_Font FH
_PrintString (sideMar + (4 * boxW - Len(monthYear$) * CW) / 2, yTitle), monthYear$
_Font FH2
End If
'printer prep
landscape& = _NewImage(YMAX, XMAX, 32)
_MapTriangle (XMAX, 0)-(0, 0)-(0, YMAX), 0 To(0, 0)-(0, XMAX)-(YMAX, XMAX), landscape&
_MapTriangle (XMAX, 0)-(XMAX, YMAX)-(0, YMAX), 0 To(0, 0)-(YMAX, 0)-(YMAX, XMAX), landscape&
' next 3 lines 2 on/off 3rd vice versa
_PrintImage landscape& '<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<< debug first before wasting paper and ink
_Delay .5 ' when printing
'Sleep ' >>>>>>>>>>>>>> when editing and checking next calendar
Next
Function leapYear% (yr) 'from Pete's calendar this is a very clear calc , mod to return 1 if leap year
If yr Mod 4 = 0 Then
If yr Mod 100 = 0 Then
If yr Mod 400 = 0 Then leapYear% = 1
Else
leapYear = 1
End If
End If
End Function
Sub Easter (givenYear As Integer, rtnMonth As Integer, rtnDay As Integer)
' Easter date calculator by Carter from SmallBASIC FLTK pack 1 of 3 given for Easter
' This one is restricted to years 1900 to 2099
Dim tb As Integer, td As Integer, te As Integer
tb = 225 - 11 * (givenYear Mod 19)
td = (tb - 21) Mod 30 + 21
te = (givenYear + givenYear \ 4 + td + 1) Mod 7
rtnDay = td + 7 - te
If rtnDay < 32 Then
rtnMonth = 3
Else
rtnDay = rtnDay - 31
rtnMonth = 4
End If
End SubThis is nice demo how to print out your own form also!
Note: this February was the first calendar I ever printed out that only needed 4 Rows for weeks, 28 days started exactly on Sunday. Totally unexpected and it leaves out the Month and year label at the top. A fluke! not likely to happen again for years!
Comment #2: this code works fine for a Canon printer that uses toner! And I have to say a Toner printer instead of a Ink printer is a million times less frustrating NOT having to deal with dried up ink problems!!! I recommend highly unless you print out photos and use printer more than a couple times a year.
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

