Pocket Calendar (Calendar)
- Type
- Utility
- Category
- Perpetual calendar printer
- Author
- Bill Lukeroth
- Published in
- Antic, January 1984 (Vol. 2, No. 10), "Pocket Calendars for 1984"
- Year
- 1984
- Language
- Atari BASIC
- Requirements
- 16K RAM, Atari BASIC; a printer (written for 40-column printers such as the Atari 820, 822 and 1020, and should work on 80-column ones) or the screen
- Tags
- antic, calendar, printer, atari-820, utility, perpetual-calendar, bill-lukeroth, 1984
About the program
Bill Lukeroth was watching his Atari 820 printer "lazily churn out a program listing" when he realised that, apart from listings and address labels, he'd found almost no use for it. "This state of affairs offended my frugal Teutonic sensibilities." The four-inch paper strips of the 820, 822, 1020 and Alphacom printers, he noticed, are just the right size for a pocket appointment calendar. So he wrote a perpetual calendar program, which "in a burst of non-creativity" he called Calendar.
Give it a month and a year, and it prints a calendar about 9 by 4 inches, with the dates under the right days of the week and a box for each day to write your appointments in. Fold it up and put it in your wallet. The magazine also printed a companion program, Sidewinder, which used the 820's sideways printing for a prettier calendar. That one works only on the 820, and it isn't reproduced here.
Typing it in
The listing is plain text apart from the inverse S and P in line 5166 ({inv}…{/inv}: press the Atari key before and after). The vertical bars in line 110 are the ordinary | key (SHIFT-=). The REM in line 95 spells the name "CALENDER", as does the disk file name.
How to use it
RUN it, type the month as a number (1 for January, not the name) and press RETURN, then the year (1950 or later). Choose S to show the calendar on screen or P for the printer, and switch the printer on first, because it starts almost at once. Each week is a row of seven boxes, Sunday to Saturday, several lines deep.
How it works
- Finding the first day. The program counts forward from 1950, using
STARTOFFfor the weekday on which that year began. Each year moves the start of the year on by one weekday, or two after a leap year (lines 5030–5100). Leap years are simply every year divisible by 4, which is correct for the whole range from 1950 to 2099. - Month lengths are stored as differences. The DATA in lines 10010–10020 gives each month's name and how many days short of 31 it is (February 3, April 1 and so on). Line 810 turns February's 3 into 2 in leap years. Line 840 uses the same number to move the starting weekday on to the next month.
- Drawing the grid.
B$is one row of empty boxes andDL$a dashed rule. For each week the program copiesB$toT1B$, writes the day numbers into the right columns with string assignment (lines 5260–5290), and prints the row followed by six blank rows for notes. - Line 5168 makes the output device from your answer (
S:orP:) by adding a colon toP$, so the samePRINT #1statements serve both the screen and the printer.
Listing
95 REM *****CALENDER*****
96 REM *BY BILL LUKEROTH*
97 REM * ANTIC MAGAZINE *
98 REM * JANUARY, 1984 *
99 REM ******************
100 DIM B$(36),T1B$(36),DL$(36),DAY(42),M$(10),P$(2)
110 B$="| | | | | | | |"
120 DL$="------------------------------------"
130 BASEYEAR=1950:STARTOFF=0:LEAPFLAG=0:CUROFF=450
140 GRAPHICS 0:GOTO 5000
440 REM ++++++++++ curoff ++++++++++
450 POKE 752,1:RETURN :REM turn cursor off
800 READ M$,ML
810 IF ML=3 AND YEAR/4=INT(YEAR/4) THEN ML=2
830 OFFSET=TEMPOFF
840 IF L2<MONTH THEN TEMPOFF=(OFFSET+3)-ML
845 IF TEMPOFF>=7 THEN TEMPOFF=TEMPOFF-7
850 RETURN
5000 ? "CALENDAR FOR WHAT MONTH(INPUT NUMBER, NOT NAME)";:INPUT MONTH
5010 ? :? "FOR WHAT YEAR";:INPUT YEAR:LEAPFLAG=0
5020 IF YEAR<BASEYEAR THEN ? :GOTO 5010
5030 DIF=YEAR-BASEYEAR:TEMPOFF=STARTOFF:TEMPYEAR=BASEYEAR
5040 FOR L=1 TO DIF
5050 TEMPOFF=TEMPOFF+1:TEMPYEAR=TEMPYEAR+1
5060 IF TEMPYEAR/4=INT(TEMPYEAR/4) THEN TEMPOFF=TEMPOFF+1
5070 IF TEMPOFF>=7 THEN TEMPOFF=TEMPOFF-7
5080 NEXT L
5090 IF YEAR/4=INT(YEAR/4) THEN LEAPFLAG=1
5100 IF LEAPFLAG=1 THEN TEMPOFF=TEMPOFF-1:IF TEMPOFF<0 THEN TEMPOFF=TEMPOFF+7
5110 FOR L2=1 TO MONTH
5120 GOSUB 800
5150 NEXT L2
5160 OFFSET=TEMPOFF
5165 T1B$=B$
5166 ? "DO YOU WANT THIS ON THE:":? " {inv}S{/inv}CREEN":? " {inv}P{/inv}RINTER":? :? "(TYPE S OR P)":INPUT P$
5167 IF P$<>"S" AND P$<>"P" THEN ? :GOTO 5166
5168 P$(2,2)=":":OPEN #1,8,0,P$:GOSUB CUROFF
5170 ? #1;" ";M$:? #1;
5180 ? #1;" S M T W T F S"
5190 ? #1;DL$
5200 FOR L3=1 TO 42:DAY(L3)=0:NEXT L3
5210 FOR L4=1 TO 42
5220 DAY(L4)=L4-OFFSET:IF DAY(L4)<0 THEN DAY(L4)=0
5230 IF L4-OFFSET>30-ML THEN L4=1:POP :GOTO 5250
5240 NEXT L4
5250 LD=-2
5255 FOR L5=1 TO 42
5260 LD=LD+5:IF LD>33 THEN ? #1;T1B$:? #1;B$:? #1;B$:? #1;B$:? #1;B$:? #1;B$:? #1;B$:? #1;DL$:T1B$=B$:LD=3
5270 IF DAY(L5)=0 THEN 5400
5280 IF DAY(L5)<10 THEN T1B$(LD+1,LD+1)=STR$(DAY(L5)):GOTO 5400
5290 T1B$(LD,LD+1)=STR$(DAY(L5))
5400 NEXT L5
5410 ? #1;T1B$:? #1;B$:? #1;B$:? #1;B$:? #1;B$:? #1;B$:? #1;B$:? #1;DL$
9999 END
10010 DATA JANUARY,0,FEBRUARY,3,MARCH,0,APRIL,1,MAY,0,JUNE,1,JULY,0,AUGUST,0,SEPTEMBER,1,OCTOBER,0,NOVEMBER,1
10020 DATA DECEMBER,0
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: CALENDER.BAS.
Credits
- Program listing: Pocket Calendar (Calendar) — program listing (Antic, January 1984 (Vol. 2, No. 10), "Pocket Calendars for 1984") — Bill Lukeroth
- Antic, January 1984 (Vol. 2 No. 10): Pocket Calendars for 1984, by Bill Lukeroth (atarimagazines.com) — Bill Lukeroth, 1984
- Antic disk, January 1984 - Vol. 2 No. 10: CALENDER.BAS (detokenized listing) — AtariMagazines.com (Kevin Savetz), 1984
