CALENDARS

by Gordon
http://sionet.mysite.wanadoo-members.co.uk/LBcode.htm

Here is a little program to print either a whole year’s calendar or for just one month. Not being a great mathematician I freely admit it is largely based on one published in a book in 1983 --- like many of my efforts. It never ceases to amuse me the trouble some folks go to devising new programs, when quite often much the same thing was produced many years ago, This is why I always suggest ardent programmers always keep an eye out for any books on old programs to provide the ideas for new programs, now we have software like Liberty basic and Just Basic to enhance the originals. This version is in turn based on part of a previous version to be found on my site in LB.

Some of the slightly unusual features of this program are for example the way a Graphics window is used instead of a Text window of the LB version, to locate all the complex printing in the exact position using the place x y function. This explains why the values of 8 and 12 appears in the calculations, as being the pixel spacing needed to position the print. As there is no easy way to create a printout screen dump with JB, I have suggested using the standard screen capture available with Windows 98 onwards of pressing Alt+PrintScreen to allow the screen to be Pasted into a variety of other software. This is why the the WindowWidth/Height is set to strange values to ensure only the relevant part of a window is captured.

Actually a Graphics window has advantages over a Text window in that we can change colors anytime we wish, or even font size just for the month/year if you wish to experiment. A Text window with LB does have the advantage of allowing the print to be copied from a temporary hidden texteditor to the main text window, and to recognize each individual character for a screen dump to printer with lprint.


nomainwin
[pick]
    WindowWidth=800 : WindowHeight=430
    menu #1, "OPTIONS", "Full year", [full], "One month", [one], |, "quit", [quit]
    open "Calendar Choice" for graphics_nsb as #1
    #1 "trapclose [quit]; down; font arial 30 bold; color darkgreen; place 100 100"
    #1 "\YEAR OR MONTH CALENDARS"
    #1 "font arial 16 bold; place 140 150"
    #1 "\press Alt+PrintScreen to capture a calendar to"
    #1 "\Paste to Word, Wordpad, Paint etc for printouts."
    dim dn$(50) : dim cl$(50, 50) : dim z$(50)
    playwave "beep" : wait

[full] f = 1 : goto [start]
[one] f = 0
    prompt"which month 1/12"; m$ : c = val(m$)
    if c = 0 then playwave "chord" : wait

[start]
    close #1
    if f = 0 then WindowWidth=400 : WindowHeight=340
    menu #1, "OPTIONS", "Full year", [full], "One month", [one], |, "quit", [quit]
    open "CALENDAR" for graphics_nsb as #1
    #1 "trapclose [quit]; down; font fixedsys"
    prompt "which year"; a$ : y = val(a$)
    if y = 0 then playwave "chord" : wait
    fcal=1 : tf=80 : c = 1 : t = 0: l = 0
[again]
    redim dn$(50) : redim cl$(50, 50) : redim z$(50)
    restore [dat]
    for n = 1 to 12: read i$ : z$(n)=i$ : next n
    for i = 1 to 7: read i$ : dn$(i)=i$ : next i
    mt = 0 : if f = 1 then mn$ = z$(c)
    while mt < c
        read mn$, fom, dm: mt = mt + 1
    wend
    yer = y: yr = y
    if yer > 1900 then yr = yr - 1900
    nly = int(yr / 4): ly = 0
    if yr mod 4 = 0 then ly = 1
    os = yr + nly
    if ly and mt < 3 then os = os - 1
    if ly and mt = 2 then dm = 29
    os =os mod 7 : tt=fom+os
    fom = tt mod 7
    if fom = 0 then fom = 7
    for i = 1 to fom - 1
        cl$(i, 1) = " "
    next i: day = 1
    for i = fom to 7
        cl$(i, 1) = str$(day)
        day = day + 1
    next i
    for j = 2 to 6
        for i = 1 to 7
            cl$(i, j) = str$(day)
            day = day + 1
            if day > dm then i = 7: j = 6
        next i
    next j
    if f = 0 goto [month]

    ' FULL YEAR
    t$= "\"+mn$+ " "+ str$(yer)
    #1 "color blue; place ";(5+t)*8;" ";(1.5+l)*12 : #1 t$;
    #1 "color black"
    for i = 1 to 7
        t$="\"+dn$(i)
        #1 "place ";(4+t)*8;" ";(i+l+2)*12 : #1 t$;
    next i
    for j = 1 to 6
        for i = 1 to 7
            v = i + l + 2
            h = j * 3 + 5 + t
            t$="\"+cl$(i,j)
            #1 "place ";h*8;" ";v*12 : #1 t$;
        next i
    next j
    c = c + 1: t = t + 24
    if t > tf then t = 0: l = l + 11
    if c < 13 goto [again]
    #1 "flush" : wait

[month]
    t$="\"+mn$+" "+str$(yer)
    #1 "color blue; place ";150;" ";24 : #1 t$;
    #1 "color black" : p = 4
    for i = 1 to 7
        t$="\"+dn$(i)
        #1 "place ";8;" ";p*12 : #1 t$;
        p = p + 3
    next i
    for j = 1 to 6
        p = 4
        for i = 1 to 7
            h = j * 7
            t$="\"+cl$(i,j)
            #1 "place ";h*8;" ";p*12 : #1 t$;
            p = p + 3
        next i
    next j : wait

[quit]
    close #1 : end

[dat]
    DATA "January","February","March","April","May"
    DATA "June","July","August","September","October","November","December"
    DATA "Mon","Tue","Wed","Thu","Fri","Sat","Sun"
    DATA "January",1,31,"February",4,28,"March",4,31,"April",7,30
    DATA "May",2,31,"June",5,30,"July",7,31,"August",3,31,"September",6,30
    DATA "October",1,31,"November",4,30,"December",6,31
    DATA 0,3,3,6,1,4,6,2,5,0,3,5,"Sunday","Monday","Tuesday"
    DATA "Wednesday","Thursday","Friday","Saturday","Sunday"
    end