-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcalendar.bas
183 lines (167 loc) · 4.26 KB
/
calendar.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
' Antonio & Alfonso De Pasquale
' Copyright (C) 1993 DOS Resource Guide
' Published in Issue #8, March 1993, page 47
'
' PERPETUAL CALENDAR PROGRAM
Setup:
CLS
CLEAR
DIM Year(12, 6, 7), Month$(12), Month(12), Day$(7)
FOR X = 1 TO 12
FOR Y = 0 TO 6
FOR Z = 0 TO 7
Year(X, Y, Z) = 0
NEXT Z
NEXT Y
NEXT X
GetYear:
CLS
PRINT TAB(30); "Calendar Creator"
PRINT
PRINT TAB(20); "By Antonio and Alfonso De Pasquale"
PRINT
INPUT "What is the calendar year you want"; Year$
YR = VAL(Year$)
IF YR < 1753 THEN
PRINT
PRINT "Year must be greater than 1752. ";
INPUT "Press <Enter> to try again"; A$
GOTO GetYear
END IF
PRINT
PRINT "Please make sure your printer is turned on and is on-line"
PRINT "Also, make sure the paper is set to the top of the form"
PRINT
INPUT "Press <Enter> when you are ready to continue"; A$
PRINT
PRINT "Calculating dates...please wait"
PRINT
CalcYear:
C = INT(YR / 100)
IF RIGHT$(STR$(YR), 2) = "00" THEN C = C - 1
D = (YR - (100 * C)) - 1
IF D = -1 THEN D = 99
K = 1
M = 11
X = (INT(2.6 * M - .2) + K + D + INT(D / 4) + INT(C / 4) - (2 * C)) / 7
G = ABS(X - INT(X))
F = INT(7 * G + .00001) + 1
IF (YR / 4) = INT(YR / 4) AND RIGHT$(Year$, 2) <> "00" THEN
LY = 1
GOTO FillYear
END IF
IF (YR / 400) = INT(YR / 400) AND RIGHT$(Year$, 2) = "00" THEN
LY = 1
GOTO FillYear
END IF
LY = 0
FillYear:
FOR X = 1 TO 7
READ Day$(X)
NEXT X
FOR X = 1 TO 12
READ Month$(X)
NEXT X
FOR X = 1 TO 12
READ Month(X)
NEXT X
IF LY = 1 THEN Month(2) = 29
FOR X = 1 TO 12
R = 1
FOR G = 1 TO Month(X)
Year(X, R, F) = G
F = F + 1
IF F = 8 THEN F = 1: R = R + 1
NEXT G
NEXT X
DATA S,M,T,W,T,F,S
DATA JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY
DATA AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER
DATA 31,28,31,30,31,30,31,31,30,31,30,31
BuildCalendar:
LPRINT
LPRINT
LPRINT SPACE$(36);
FOR X = 1 TO 5
LPRINT MID$(Year$, X, 1); " ";
NEXT X
LPRINT
LPRINT
FOR I = 1 TO 12 STEP 2
GOSUB PrintStars
GOSUB PrintMonth
GOSUB PrintWeek
FOR Week = 1 TO 6
LPRINT SPACE$(7);
LPRINT "* ";
FOR X = 1 TO 7
SELECT CASE Year(I, Week, X)
CASE IS = 0
LPRINT SPACE$(4);
CASE IS < 10
SPV = 1
LPRINT SPACE$(SPV); Year(I, Week, X);
CASE IS > 9
SPV = 0
LPRINT SPACE$(SPV); Year(I, Week, X);
END SELECT
NEXT X
LPRINT SPACE$(2); "* ";
FOR X = 1 TO 7
SELECT CASE Year(I + 1, Week, X)
CASE IS = 0
LPRINT SPACE$(4);
CASE IS < 10
SPV = 1
LPRINT SPACE$(SPV); Year(I + 1, Week, X);
CASE IS > 9
SPV = 0
LPRINT SPACE$(SPV); Year(I + 1, Week, X);
END SELECT
NEXT X
LPRINT SPACE$(2); "*"
NEXT Week
NEXT I
GOSUB PrintStars
LPRINT CHR$(12)
PRINT "Calendar has been printed."
END
PrintStars:
LPRINT SPACE$(7);
FOR A = 1 TO 65
LPRINT "*";
NEXT A
LPRINT
RETURN
PrintMonth:
FOR B = 1 TO 12 STEP 2
IF B = I THEN
GOSUB FindMonth
END IF
NEXT B
RETURN
PrintWeek:
LPRINT SPACE$(7);
LPRINT "*"; SPACE$(3);
FOR D = 1 TO 2
FOR D1 = 1 TO 7
LPRINT Day$(D1); SPACE$(3);
NEXT D1
LPRINT "*"; SPACE$(3);
NEXT D
LPRINT
RETURN
FindMonth:
T1 = LEN(Month$(B))
T2 = LEN(Month$(B + 1))
T3 = INT((33 - T1) / 2)
T4 = INT((33 - T2) / 2)
LPRINT SPACE$(7); "*";
LPRINT SPACE$(T3); Month$(B);
RT = 33 - T3 - T1
LPRINT SPACE$(RT - 2); "*";
LPRINT SPACE$(T4); Month$(B + 1);
RT = 33 - T4 - T2
LPRINT SPACE$(RT - 2); "*";
LPRINT
RETURN