10 REM ***** THE TIME MACHINE *****
20 REM ***** FROM NOV 1983 POPULAR COMPUTING *****
30 REM ***** FILED UNDER "TIMEMACH" *****
40 REM ***** OCT 1983 PGB *****
50 RESET
60 DEFINT A-Z
70 CLEAR 500
80 CW=11:CL=5:VL$=":":HL$="-"
90 PW=CW*7+1:R$=STRING$(PW-1,HL$):NB=CL-1
100 OF=INT((CW-3)/2)+1
110 BC$=VL$+STRING$(CW-1," ")
120 CN$=VL$+STRING$(CW-3," ")+"##"
130 MF$=VL$+"\"+STRING$(CW-3," ")+"\"
140 DIM MO$(12),MD(12),C(42),NL$(42,NB),WY$(7)
150 FOR I=1 TO 12:READ MO$(I):NEXT I
160 DATA JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY
170 DATA AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER
180 FOR I=1 TO 12:READ MD(I):NEXT I
190 DATA 31,28,31,30,31,30,31,31,30,31,30,31
200 FOR I=1 TO 7:READ WY$(I):NEXT I
210 DATA SUN,MON,TUE,WED,THU,FRI,SAT
220 PRINT "THE TIME MACHINE: A CALENDAR GENERATOR"
230 PRINT "--- ---- -------  - -------- ---------"
240  PRINT:PRINT "INPUT THE CALENDAR MONTH AS:MONTH,YEAR."
250 PRINT:PRINT "FOR EXAMPLE:'1,1984' FOR JANUARY 1984"
260 PRINT:PRINT "VALID MONTHS ARE 3,1920 THROUGH 11,2009"
270 PRINT:INPUT "NOW TYPE IN THE MONTH,YEAR     ";M,Y
280 IF Y<1920 OR Y>2009 THEN 260
290 IF Y=1920 AND M<3 THEN 260
300 IF Y=2009 AND M>11 THEN 260
310 IF M<1 OR M>12 THEN 260
320 PRINT:PRINT "CREATING A CALENDAR FOR ";MO$(M);Y
330 FOR I= 1 TO 42:C(I)=0:FOR J= 1 TO NB:NL$(I,J)="":NEXT J:NEXT I
340 D=1
350 Y1!=Y-1920
360 IF M>2 THEN M1!=M-3 ELSE M1!=M+9:Y1!=Y1!-1
370 JD!=INT(1461*Y1!/4)+INT((153*M1!+2)/5)+D-1
380 WD = (JD!+1) MOD 7
390 IF (Y MOD 4 = 0 AND Y MOD 100 <>0) OR Y MOD 400 = 0

      THEN LP = 1 ELSE LP = 0
400 IF (Y2=0 AND Y3<>=0)OR Y4=0 THEN LP=1 ELSE LP=0
410 LD = MD(M):IF LP=1 AND M=2 THEN LD=29
420 FOR I=1 TO LD:C(I+WD)=I:NEXT I
430 PRINT:PRINT "TO ANNOTATE A DATE,TYPE IN THE DATE(1-"LD");"
440 PRINT:INPUT "TYPE 0 WHEN FINISHED";SD
450 IF SD<1 OR SD >LD THEN 530
460 PRINT:PRINT "ENTER UP TO "NB"LINES. MAXIMUM LINE LENGTH IS "CW-1
470 FOR I=1 TO NB
480 PRINT:PRINT "ENTER LINE";I;
490 TX$="":INPUT TX$
500 NL$(WD+SD,I)=TX$
510 NEXT I
520 PRINT:PRINT "TEXT STORED. ":GOTO 430
530 PRINT:PRINT:PRINT R$
540 H$=MO$(M)+STR$(Y):LH=LEN(H$):TB=INT((PW-LH)/2)+1
550 PRINT VL$ TAB(TB)H$ TAB(PW-1)VL$
560 PRINT R$
570 PRINT VL$;
580 FOR DA=1 TO 7
590 TB=(DA-1)*CW+OF
600 PRINT TAB(TB) WY$(DA);
610 NEXT DA
620 PRINT TAB(PW-1)VL$:PRINT R$
630 LW=-INT(-(LD+WD)/7)
640 FOR W=1 TO LW
650 FOR ML =1 TO NB
660 FOR DA= 1 TO 7
670 TB=(DA-1)*CW
680 PRINT TAB(TB) VL$;NL$(DA+(W-1)*7,ML);
690 NEXT DA:PRINT TAB(PW-1)VL$:NEXT ML
700 FOR DA=1 TO 7
710 TB=(DA-1)*CW
720 DN=DA+(W-1)*7
730 IF C(DN)=0 THEN PRINT TAB(TB)BC$;:GOTO 750
740 PRINT TAB(TB) VL$;C(DN);
750 NEXT DA
760 PRINT TAB(PW-1) VL$:PRINT R$
770 NEXT W
780 RESET
790 PRINT:PRINT:INPUT"DO YOU WANT HARD COPY  ";X$
800 IF X$ <>"Y" GOTO 1080
810 LPRINT:LPRINT:LPRINT R$
820 H$=MO$(M)+STR$(Y):LH=LEN(H$):TB=INT((PW-LH)/2)+1
830 LPRINT VL$ TAB(TB)H$ TAB(PW-1)VL$
840 LPRINT R$
850 LPRINT VL$;
860 FOR DA=1 TO 7
870 TB=(DA-1)*CW+OF
880 LPRINT TAB(TB) WY$(DA);
890 NEXT DA
900 LPRINT TAB(PW-1)VL$:LPRINT R$
910 LW=-INT(-(LD+WD)/7)
920 FOR W=1 TO LW
930 FOR ML =1 TO NB
940 FOR DA=1 TO 7
950 TB=(DA-1)*CW
960 LPRINT TAB(TB) VL$;NL$(DA+(W-1)*7,ML);
970 NEXT DA:LPRINT TAB(PW-1)VL$:NEXT ML
980 FOR DA=1 TO 7
990 TB=(DA-1)*CW
1000 DN=DA+(W-1)*7
1010 IF C(DN)=0 THEN LPRINT TAB(TB)BC$;:GOTO 1030
1020 LPRINT TAB(TB) VL$ ;C(DN);
1030 NEXT DA
1040 LPRINT TAB(PW-1) VL$:LPRINT R$
1050 NEXT W
1060 LPRINT CHR$(12):INPUT "DO YOU WANT ANOTHER HARD COPY ";Y$
1070 IF Y$="Y" GOTO 810
1080 PRINT:PRINT "END OF PROCESSING"
1090 RESET
1100 RUN "MENU"
