'This is my very first calendar making program!
'Thanks to the guys from the QB64.org forum for the help: bplus, SMcNeill, euklides, and TempodiBasic!
'This is a freeware program like all my other programs and games, only free.
'Feel free to use this code in your own programs.
'This version has the ability to add info or holidays to dates.
'Made on Thursday, September 19, 2019 by Ken G.
start:
dd = 0
leap = 0
m = 0
mm = 0
y = 0
yy = 0
w = 0
weekday = 0
days = 0
holidays = 0
PRINT " Monthly Calendar Maker" PRINT " With some help from the QB64.org Forum guys!" PRINT " This program will make a calendar for the year and month you want." PRINT " It will also name some U.S. holidays on their dates if you choose that." PRINT " You also can add holidays or info to any day you wish with up to 12" PRINT " letters, numbers, symbols, or spaces." PRINT " This uses the Gregorian Calendar which became common practice in" PRINT " England in 1753 and we still use it today." PRINT " First make a calendar, then if you want to save it as a .bmp file," PRINT " press the 'S' key and it will save it as the month and year for its name." PRINT " For example, if you made a calendar for January 2020 and wish to save it," PRINT " press the 'S' key and it will save it as 1-2020.bmp" PRINT " If you wish to print your calendar on your printer, press 'P' once." PRINT " Feel free to print as many times as you wish. They take up 1 page each." PRINT " If you save the .bmp calendar, it will be put in the same directory as this program." PRINT " To switch to the last month use the left arrow key, to the next month the right arrow key." PRINT " Switching months with the arrow keys will not save your new date info if you come back." PRINT " To make a different calendar without saving, press the Space Bar." PRINT " Keyboard commands will be listed on the title bar of the window." again1:
INPUT " Type the year here (1753-9999): ", y
IF y
< 1753 OR y
> 9999 THEN PRINT "The year can only be between 1753 and 9999, try again.":
GOTO again1:
again2:
INPUT " Type the month here (1-12): ", m
INPUT " Do you want U.S. holidays added (Y/N)?", hol$
INPUT " Do you want to add your own holidays or info (Y/N)?", adding$
calculate:
info = 0
infos = 0
'Get the month name.
IF m
= 1 THEN month$
= " January" IF m
= 2 THEN month$
= "February" IF m
= 3 THEN month$
= " March" IF m
= 4 THEN month$
= " April" IF m
= 6 THEN month$
= " June" IF m
= 7 THEN month$
= " July" IF m
= 8 THEN month$
= " August" IF m
= 9 THEN month$
= "September" IF m
= 10 THEN month$
= " October" IF m
= 11 THEN month$
= "November" IF m
= 12 THEN month$
= "December"
'Calculate to see if it's a Leap Year.
'Get the number of days for each month.
more:
nex:
weekday:
'Set the month, year, and weekday variables to start with.
mm = m
yy = y
GetDay mm, dd, y, weekday
adding$ = ""
'This section makes the calendar graph.
make:
_TITLE "Press 'S' to Save, 'P' to Print, Left and Right Arrow Keys To Switch Months, Space Bar For Different One, or 'Esc' to Quit."
'Finding Date of Easter
PQA = yy
'month = PQM, day = PQJ, year = PQA
'This section puts the right dates and holidays in the right squares for the calendar.
w = (weekday * 108) + 25
dd = dd + 1
GetDay mm, dd, y, weekday
infos = infos + 1
ye = 1
skip:
ye = 0
w = 25
more2:
'printer prep (code copied and pasted from bplus Free Calendar Program)
_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&
m = m + 1
m = 1
yy = yy + 1
y = yy
dd = 0
leap = 0
m = m - 1
m = 12
yy = yy - 1
y = yy
dd = 0
leap = 0
adding:
add:
olddayinfo = dayinfo(info)
info = info + 1
infos = 1
adding2:
IF info
> days
THEN PRINT "You have reached the maximum amount of holidays or info for this month.":
INPUT "Press enter to create calendar.", pe$:
RETURN PRINT "Your dates must go in order here." PRINT "for example, you cannot put info for day 15 and then put info for day 1." PRINT "They must all follow from smallest number to highest number or it will tell you to start over again." PRINT "Also, you cannot change a day by doing it over again, so if you mess up, create a new month." INPUT "Which day of the month for new holiday or information: ", dayinfo
(info
) IF dayinfo
(info
) > days
THEN PRINT "That day is not on this calendar, try again.":
GOTO adding2:
IF dayinfo
(info
) < 1 THEN PRINT "You cannot type a date less than 1, try again.":
GOTO adding2:
IF dayinfo
(info
) <> INT(dayinfo
(info
)) THEN PRINT "You cannot type a decimal for a date, try again.":
GOTO adding2:
IF dayinfo
(info
) < olddayinfo
THEN PRINT "You have put a date before your previous one which cannot work, start over from your first date." newinfo$(dl) = ""
dayinfo(dl) = 0
olddayinfo = 0
info = 0
adding3:
PRINT "Type up to 12 letters, numbers, or spaces that will be put for that day." INPUT "->", newinfo$
(info
) infoamount
= LEN(newinfo$
(info
))INPUT "Do you want to add more (Y/N):", yn$
'Color all Sundays and holidays
coloring:
LINE (dayx
- 4, weeky
- 9)-(dayx
+ 102, weeky
+ 68), _RGB32(255, 255, 127), BF:
COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 127)
'Find the right date for Easter.
PAQUES:
PQM
= INT(PQA
/ 100): PQ1
= PQA
- PQM
* 100: PQJ
= INT(((PQA
/ 19 - INT(PQA
/ 19)) + .001) * 19)PQ2
= INT(PQM
/ 4): PQ3
= INT(((PQM
/ 4) - PQ2
+ .001) * 4): PQ4
= INT((8 + PQM
) / 25)PQ5
= INT((1 + PQM
- PQ4
+ .001) / 3): PQ4
= (15 + 19 * PQJ
+ PQM
- PQ2
- PQ5
+ .001) / 30: PQ4
= PQ4
- INT(PQ4
)PQ4
= INT(PQ4
* 30): PQ5
= INT(PQ1
/ 4): PQ6
= ((PQ1
/ 4) - PQ5
) * 4PQ7
= (32 + 2 * PQ3
+ 2 * PQ5
- PQ4
- PQ6
+ .001) / 7: PQ7
= (PQ7
- INT(PQ7
)) * 7: PQ6
= (PQJ
+ 11 * PQ4
+ 22 * PQ7
) / 451PQ6
= INT(PQ6
): PQ2
= (114 + PQ4
+ PQ7
- 7 * PQ6
) / 31: PQM
= INT(PQ2
): PQJ
= INT((PQ2
- PQM
+ .001) * 31 + 1)
'This section saves the calendar to a BMP file along with the SUB at the end of this program.
saving:
nm$ = mo$ + "-"
nm$ = nm$ + year$
SaveImage 0, nm$ 'saves entire program screen,"
nm2$ = nm$ + ".bmp"
PRINT " "; nm2$;
" has been saved to your computer." INPUT " Do you wish to make another calendar (Y/N)"; ag$
weekdays:
'This section gets the right weekday.
SUB GetDay
(mm
, dd
, y
, weekday
) 'use 4 digit year 'From Zeller's congruence: https://en.wikipedia.org/wiki/Zeller%27s_congruence
IF mm
< 3 THEN mm
= mm
+ 12: y
= y
- 1 zerocentury = y \ 100
weekday
= (dd
+ INT(13 * (mm
+ 1) / 5) + century
+ INT(century
/ 4) + INT(zerocentury
/ 4) + 5 * zerocentury
) MOD 7
'This section saves the .bmp picture file.
IF bytesperpixel&
= 1 THEN bpp&
= 8 ELSE bpp&
= 24 b$
= "BM????QB64????" + MKL$(40) + MKL$(x&
) + MKL$(y&
) + MKI$(1) + MKI$(bpp&
) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later) FOR c&
= 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0)) MID$(b$
, 11, 4) = MKL$(LEN(b$
)) ' image pixel data offset(BMP header) FOR py&
= y&
- 1 TO 0 STEP -1 ' read JPG image pixel color data r$ = ""
c&
= POINT(px&
, py&
) 'POINT 32 bit values are large LONG values d$ = d$ + r$ + padder$
MID$(b$
, 35, 4) = MKL$(LEN(d$
)) ' image size(BMP header) b$ = b$ + d$ ' total file data bytes to create file
MID$(b$
, 3, 4) = MKL$(LEN(b$
)) ' size of data file(BMP header)