Task

Provide an algorithm as per the Calendar task, except the entire code for the algorithm must be presented   entirely without lowercase.

Also - as per many 1969 era line printers - format the calendar to nicely fill a page that is 132 characters wide.

(Hint: manually convert the code from the Calendar task to all UPPERCASE)

This task also is inspired by Real Programmers Don't Use PASCAL by Ed Post, Datamation, volume 29 number 7, July 1983.

THE REAL PROGRAMMER'S NATURAL HABITAT
"Taped to the wall is a line-printer Snoopy calender for the year 1969."

Moreover this task is further inspired by the long lost corollary article titled:

"Real programmers think in UPPERCASE"!

Note: Whereas today we only need to worry about ASCII, UTF-8, UTF-16, UTF-32, UTF-7 and UTF-EBCDIC encodings, in the 1960s having code in UPPERCASE was often mandatory as characters were often stuffed into 36-bit words as 6 lots of 6-bit characters. More extreme words sizes include 60-bit words of the CDC 6000 series computers. The Soviets even had a national character set that was inclusive of all
4-bit,
5-bit,
6-bit &
7-bit depending on how the file was opened... And one rogue Soviet university went further and built a 1.5-bit based computer.

Of course... as us Boomers have turned into Geezers we have become HARD OF HEARING,
and suffer from chronic Presbyopia, hence programming in UPPERCASE
is less to do with computer architecture and more to do with practically. :-)

For economy of size, do not actually include Snoopy generation
in either the code or the output, instead just output a place-holder.

FYI: a nice ASCII art file of Snoopy can be found at textfiles.com. Save with a .txt extension.

Trivia: The terms uppercase and lowercase date back to the early days of the mechanical printing press. Individual metal alloy casts of each needed letter, or punctuation symbol, were meticulously added to a press block, by hand, before rolling out copies of a page. These metal casts were stored and organized in wooden cases. The more often needed minuscule letters were placed closer to hand, in the lower cases of the work bench. The less often needed, capitalized, majuscule letters, ended up in the harder to reach upper cases.




' VERSION 16-03-2016
' COMPILE WITH: FBC -S CONSOLE
 
' TRUE/FALSE ARE BUILT-IN CONSTANTS SINCE FREEBASIC 1.04
' BUT WE HAVE TO DEFINE THEM FOR OLDER VERSIONS.
#IFNDEF TRUE
    #DEFINE FALSE 0
    #DEFINE TRUE NOT FALSE
#ENDIF
 
FUNCTION WD(M AS INTEGER, D AS INTEGER, Y AS INTEGER) AS INTEGER
    ' ZELLERISH
    ' 0 = SUNDAY, 1 = MONDAY, 2 = TUESDAY, 3 = WEDNESDAY
    ' 4 = THURSDAY, 5 = FRIDAY, 6 = SATURDAY
 
    IF M < 3 THEN        ' IF M = 1 OR M = 2 THEN
        M += 12
        Y -= 1
    END IF
    RETURN (Y + (Y \ 4) - (Y \ 100) + (Y \ 400) + D + ((153 * M + 8) \ 5)) MOD 7
END FUNCTION
 
FUNCTION LEAPYEAR(Y AS INTEGER) AS INTEGER
 
    IF (Y MOD 4) <> 0 THEN RETURN FALSE
    IF (Y MOD 100) = 0 ANDALSO (Y MOD 400) <> 0 THEN RETURN FALSE
    RETURN TRUE
END FUNCTION
 
' ------=< MAIN >=------
' HARD CODED FOR 132 CHARACTERS PER LINE
 
DIM AS STRING WDN = "MO TU WE TH FR SA SU"  ' WEEKDAY NAMES
DIM AS STRING MO(1 TO 12) => {"JANUARY", "FEBRUARY", "MARCH", "APRIL", _
                         "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", _
                                    "OCTOBER", "NOVEMBER", "DECEMBER"}
DIM AS STRING TMP1, TMP2, D(1 TO 12)
 
DIM AS UINTEGER ML(1 TO 12) => {31,28,31,30,31,30,31,31,30,31,30,31}
DIM AS UINTEGER I, I1, J, K, Y = 1969
 
'SCREENRES 1080,600,8
 
IF LEAPYEAR(Y) = TRUE THEN ML(2) = 29
 
TMP1 = ""
FOR I = 1 TO 31
    TMP1 = TMP1 + RIGHT(("  " + STR(I)), 3)
NEXT I
 
 
FOR I = 1 TO 12
    TMP2 = ""
    J = WD(I,1, Y)
    IF J = 0 THEN J = 7
    J = J - 1
    TMP2 = SPACE(J * 3) + LEFT(TMP1, ML(I) * 3) + SPACE(21)
    D(I) = TMP2
NEXT I
 
PRINT
TMP1 = "INSERT YOUR SNOOPY PICTURE HERE"
PRINT SPACE((132 - LEN(TMP1)) \ 2); TMP1
PRINT
TMP1 = STR(Y)
PRINT SPACE((132 - LEN(TMP1)) \ 2); TMP1
PRINT
 
' 6 MONTH ON A ROW
TMP2 = " "
FOR I = 1 TO 6
    TMP2 = TMP2 + WDN
    IF I < 6 THEN TMP2 = TMP2 + "  "
NEXT I
 
FOR I = 1 TO 12 STEP 6
    TMP1 = ""
    FOR J = I TO I + 4
        TMP1 = TMP1 + LEFT(SPACE((22 - LEN(MO(J))) \ 2) + MO(J) + SPACE(11), 22)
    NEXT J
    TMP1 = TMP1 + SPACE((22 - LEN(MO(I + 5))) \ 2) + MO(I + 5)
    PRINT TMP1
    PRINT TMP2
    FOR J = 1 TO 85 STEP 21
        FOR K = I TO I + 4
            PRINT MID(D(K), J ,21); " ";
        NEXT K
        PRINT MID(D(I + 5), J ,21)
    NEXT J
    PRINT
NEXT I
 
' EMPTY KEYBOARD BUFFER
WHILE INKEY <> "" : WEND
PRINT : PRINT "HIT ANY KEY TO END PROGRAM"
SLEEP
END