Beebug


Perpetual Calendar

 
Author: Peter Brown
Published in Beebug Volume 9 Number 8

Perpetual Calendar

Although the subject of calendars has been touched on before in Beebug I've never really found a program which meets my needs. This one, hopefully, meets all requirements.

The internal calendar in the Master 128 is very accurate and useful in its own right as an instant-access calendar. However, it does not allow you to look at other dates or whole months at a time, and cannot cope with dates before 1900 or after 1999. The program listed here can display or print the calendar month by month for any year between 1753 and 5000 A.D. in the United Kingdom, or even earlier in other countries.

How To Use The Program

Type in the program as in the listing and then save it - the program is written entirely in Basic, so there should be no real problems, but watch out for the abbreviation of 'September' in line 1550 to 'Septemb.'. When the program is running, if you are using a Master 128 you will be faced with the calendar for the current month and year. If you are using a Model B or Compact then see later in this article for details of how to change the program for use with these models. From then on the program is the same for all machines - pressing the right cursor key will step up a month, the left key down a month - the calendar changing accordingly. Pressing the up and down keys will alter the years in exactly the same way.

Pressing 'D' will let you enter the date you wish to display from the keyboard, 'P' will print the calendar for the current year in either planner format, or in monthly blocks. The 'Q' key will let you quit the program.

Using The Calendar

The program assumes that you will be using calendars for this country. Although there is no actual difference between the calendars for various countries, the date when the Gregorian calendar was adopted differs from country to country, so you will need to change the variable called gregyear in line 120 according to table 1.

Technical Notes

To adapt the program for use with the Model B or Compact you should change line 180 to PROCenterdate to make the program ask for a starting date rather than try to extract the date from the Master's TIME$.

For the model B only you will also need to remove the REM from line 160 to activate PROCdefchars, and because of space considerations, add the following move-down routine to the start of the program:

0 IF PAGE<&E00 THEN 100
1 *KEY0 *T.|MFORA%=0TO (TOP-PAGE) STEP4:A%!&E00=A%!PAGE:NEXT|MPAGE=&E00|MOLD|MRUN|M
2 *FX138,0,128

A corollary of this is that Compact and model B users can omit PROCgettoday (lines 3310 to 3400), Compact owners can omit PROCdefchars (lines 3400 to 3520), and Master owners can omit both PROCdefchars and PROCenterdate (lines 2070 to 2260).

There are also several procedures which you might like to use in your own programs:

PROCbox(leftxtab,leftytab,rightxtab,rightytab) ... draws a box using ASCII codes 166, 169 and 176-179 (which must be defined first on a Model B - see PROCdefchars). The parameters are the same as used in the Basic VDU 28 (text windowing) command.

PROClarge(xtab,ytab,text$,dt) ... is a combination of previous double and triple procedures - the parameters xtab and ytab are the x and y co-ordinates where the text is to be displayed, text$ is the text to be displayed, and lastly dt, which should be 0 if the text is to be displayed in double height or 1 if the text is to appear in triple height. Bear in mind though that if the text is to appear on consecutive lines the y tab positions should be 2 apart if they are to appear in double height, or 3 apart if they are to appear in triple height.

Extending The Program

If your printer supports quadruple height printing then you could adapt the printing procedures to print only a whole month's calendar at a time, or you could print the dates in a long strip - leaving spaces for reminders etc. There are many other possibilities for extending the printing routines in this program.

Peter Brown

This article was converted to a web page from the following pages of Beebug Volume 9 Number 8.

Beebug Volume 9 Number 8 scan of page 13

Page 13

Beebug Volume 9 Number 8 scan of page 14

Page 14

Beebug Volume 9 Number 8 scan of page 15

Page 15

Beebug Volume 9 Number 8 scan of page 16

Page 16

Beebug Volume 9 Number 8 scan of page 17

Page 17