_TITLE "Calendar" '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 inches, USA measure, with Windows 10 and HP envy 5530 printer.
CONST tMar
= 40 'top margin allows room for 3 hole binder punch on top (landscape orientation) or left side (portrait orientation) DATA "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" DATA "January","February","March","April","May","June","July","August","September","October","November","December" DATA 31,28,31,30,31,30,31,31,30,31,30,31
' this loads and checks fonts (Windows 10)
FH
= _LOADFONT("ARLRDBD.ttf", 24, "MONOSPACE")CH
= _FONTHEIGHT(FH
): CW
= CH
* .6 'this make printing char by char the same as printing a string for ARLRDBD.ttf'test font, in box? for 5 above 5 below height = 30
FH2
= _LOADFONT("ARLRDBD.ttf", 18, "MONOSPACE")CH2
= _FONTHEIGHT(FH2
): CW2
= CH2
* .5 'this make printing char by char the same as printing a string for ARLRDBD.ttfLINE (5, 45)-STEP(CW2
* LEN("testing smaller font 1, 2, 3, 31"), 25), , B
y = 2019 'free calendar
'WHILE 1
'LOCATE 10, 1
'LINE INPUT "Enter Month Number,Year Number ", ln$
'ln$ = "8, 2018" '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< just plug in year here until debugged
'm = VAL(leftOf$(ln$, ","))
'y = VAL(rightOf$(ln$, ","))
'IF m = 0 OR y = 0 THEN END
'day month starts, probably the most crucial formula from the SnallBASIC 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 + add
'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
) 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
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
LINE (sideMar
, yDayNames
- 5)-STEP(7 * boxW
, 1), , BF
'verticals and daytitles
x = sideMar + day * boxW
LINE (x
, yDayNames
- 5)-(x
+ 1, yBottomGrid
), , BF
xoff
= (boxW
- LEN(dayNames$
(day
)) * CW2
) / 2 LINE (sideMar
, yTopGrid
)-STEP(7 * boxW
, 1), , BF
' horizontals
LINE (sideMar
, yTopGrid
+ boxH
* n
)-STEP(7 * boxW
, 1), , BF
' dates
FOR i
= 0 TO monthDays
(m
) - 1 row = (d + i) \ 7
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)
_PRINTSTRING (sideMar
+ (4 * boxW
- LEN(monthYear$
) * CW
) / 2, yTitle
), monthYear$
'printer prep
_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&
'_PRINTIMAGE landscape& '<<<<<<<<<<<<<<<<<<<<<<<<< debug first before wasting paper and ink
'wend
posOf
= INSTR(source$
, of$
) IF posOf
> 0 THEN leftOf$
= MID$(source$
, 1, posOf
- 1)
posOf
= INSTR(source$
, of$
)