This program calculates the day of the week and astrological sign for any user-supplied date of birth, using Zeller’s congruence adapted for BASIC. The zodiac sign is determined by a computed GO TO branching directly to line numbers constructed as month×100+day, with dedicated lines for each sign boundary. January and February births require a year-minus-one adjustment (line 2000), splitting year input across two branches before rejoining at line 3000. The century and year-within-century are extracted separately from a four-character string input to feed Zeller’s formula.
Program Structure
The program is divided into several logical phases:
- Splash screen and safety check (lines 2–3): Displays the title and authorship, then PEEKs a system variable to decide whether to proceed or auto-save.
- Input collection (lines 10–16): Gathers day, month, and year with basic range validation. January/February births are diverted to line 2000 for the Zeller adjustment.
- Zodiac dispatch (lines 20–1299): A computed
GO TO ms*100+jjumps to one of thirteen labelled lines that PRINT the sign name. - Day-of-week output (lines 1300–1326): Clears part of the screen and prints the day name from a cascade of
IF z=ntests. - Zeller’s calculation (lines 3000–3060): Extracts century and year from the string, applies the formula, and branches to line 18 — which does not exist (see Bugs).
- Save/verify (line 9999): Stores the program to tape with
LINE 1autostart.
Key BASIC Idioms
- Computed GO TO:
GO TO ms*100+jat line 30 is the central dispatch mechanism. Line numbers encode the month-start boundary of each zodiac sign (e.g., line 1121 = 11th month, 21st day = Scorpio starts 21 November). - LINE input for year: Using
INPUT … LINE a$accepts the year as a string, allowing it to be sliced witha$(1 TO 2)anda$(3 TO 4)at lines 3010–3020 to separate century from year without string-to-number conversion ambiguity. - Cascade of IF statements for day names (lines 1320–1326) rather than an array or DATA block — typical of early hobbyist BASIC where string arrays were cumbersome.
- VAL on substrings:
VAL a$(1 TO 2)is a compact way to convert a two-digit slice to a number.
Zeller’s Congruence
Lines 3030–3040 implement Zeller’s congruence for the Gregorian calendar:
c= century (first two digits of year)a= year within century (last two digits)m= adjusted month (March = 1 … February = 12; January/February treated as months 11/12 of the previous year)- Formula:
x = INT(2.6*m - 0.199) + j + a + INT(a/4) + INT(c/4) - 2*c z = INT x - 7*INT(x/7)extracts the remainder mod 7 without theMODoperator (not available in standard Spectrum BASIC).
The January/February diversion at line 2000 sets m = ms + 10 (so January → 11, February → 12) and prompts for “Year of birth −1”, correctly decrementing the year for these months as Zeller’s algorithm requires.
Notable Techniques
| Technique | Location | Purpose |
|---|---|---|
| PEEK 23681 | Line 3 | Reads FLAGS2 system variable; bit 1 signals 64-column mode. If zero (normal mode), triggers auto-save and stop. |
| Computed GO TO | Line 30 | Dispatches to zodiac-sign lines using arithmetic on month and day. |
| Mod-7 without MOD | Line 3040 | INT x - 7*INT(x/7) computes x mod 7 for the day-of-week index. |
| SAVE … LINE 1 | Line 9999 | Saves with autostart at line 1, followed immediately by VERIFY for data integrity. |
| Erasing zone with PRINT spaces in loop | Line 1300 | Wipes lines 6–17 with blank strings before printing results. |
Content
Source Code
2 CLS : PRINT AT 8,5;"The Day You Were Born";AT 10,2;"Written by KRISTIAN BOISVERT";AT 12,8;"©1986 BYTE POWER"
3 IF PEEK 23681=0 THEN PRINT AT 15,0;: LIST 9999: STOP
10 INPUT "Day of birth:";j: IF j>31 OR j<1 THEN GO TO 10
11 INPUT "Month of birth:";ms: IF ms<1 OR ms>12 THEN GO TO 11
12 LET m=ms-2: IF ms<=2 THEN GO TO 2000
15 INPUT "Year of birth:"; LINE a$: IF LEN a$<>4 THEN GO TO 15
16 GO TO 3000
20 CLS
30 PRINT AT 5,0;"Your sign is:";: GO TO ms*100+j
119 PRINT TAB 13;"Capricorn"
217 PRINT TAB 13;"Aquarius"
320 PRINT TAB 13;"Pisces"
419 PRINT TAB 13;"Aries"
520 PRINT TAB 13;"Taurus"
620 PRINT TAB 13;"Gemini"
722 PRINT TAB 13;"Cancer"
822 PRINT TAB 13;"Leo"
922 PRINT TAB 13;"Virgo"
1022 PRINT TAB 13;"Libra"
1121 PRINT TAB 13;"Scorpio"
1221 PRINT TAB 13;"Sagittarius"
1250 PRINT TAB 13;"Capricorn"
1300 FOR x=6 TO 17: PRINT AT x,13;" ": PAUSE 10: NEXT x
1310 PRINT AT 7,0;"And you were born on a ";
1320 IF z=0 THEN PRINT "SUNDAY"
1321 IF z=1 THEN PRINT "MONDAY"
1322 IF z=2 THEN PRINT "TUESDAY"
1323 IF z=3 THEN PRINT "WEDNESDAY"
1324 IF z=4 THEN PRINT "THURSDAY"
1325 IF z=5 THEN PRINT "FRIDAY"
1326 IF z=6 THEN PRINT "SATURDAY"
1330 INPUT "Another? "; LINE q$: IF q$="n" OR q$="N" THEN STOP
1340 RUN
2000 LET m=ms+10
2010 INPUT "Year of birth -1:"; LINE a$: IF LEN a$<>4 THEN GO TO 2010
3000 CLS
3010 LET c=VAL a$(1 TO 2)
3020 LET a=VAL a$(3 TO 4)
3030 LET x=INT (2.6*m-.199)+j+a+INT (a/4)+INT (c/4)-2*c
3040 LET z=INT x-7*INT (x/7)
3060 GO TO 18
9999 SAVE "THE DAY" LINE 1: VERIFY "THE DAY"
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
