[alt.sources] [postscript] Wallet-sized Datebook Generator

brf@cbnewsi.att.com (bruce.r.fowler) (09/16/90)

Archive-name: datebook/11-Sep-90
Original-posting-by: brf@cbnewsi.att.com (bruce.r.fowler)
Original-subject: Wallet-sized Datebook Generator
Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)

[Reposted from comp.lang.postscript.
Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).]

Dear NetFriends,

	Attached is a chunk of PostScript that prints up wallet-sized
appointment calendars for a specified month.  It was inspired by the
recent calendar.ps program and uses some of the same code.

	The month is selected by editing the source at line 15 or so.
Trim the results with sissors or papper cutter leaving a small margin
outside the border lines.  Fold in fourths, accordian-style, toward
you on the center vertical line and away from you on the other two.
This results in a 2.5" by 3.5" four-sheet-thick datebook that will
slip easily into your wallet, eliminating the need for that ugly bulge
where you used to have to carry that full-year schedule book.  :-)

	You have about .4" by 2" of writing space for each day, so
this is not so good for very busy people, but if you just need to keep
track of dentist appointments or when the next lodge meeting is, this
is for you.  And you can always put extra notes on the back.

	BTW, I much enjoy reading this group, and have gotten a lot
of useful information from it.  On the other hand, this is my third
posting in the last six months (the other two being a "lines-not-read"
mod to the Adobe green book error handler, and a game board for "hex").
So far I have gotten zero feedback.  So I am not sure if my articles
are being eaten by the news server, or if people think that this kind
of posting is a waste of bandwith, or if you are all sitting on the
edge of your chairs waiting to see my byline again, or what.  Without
generating too much traffic, maybe one of the regular contributors to
this group could email to let me know that this got out.  Thanks.

						      Bruce Fowler
	   AT&T HR 2F-027 201-615-5559 Dept 51223 brf@mink.att.com
	  +-------------------------------------------------------+
	  |  ***   The Twilight Zone - Love it or Leave it.  ***  |
	  +-------------------------------------------------------+

 ____  ==> [ unzip here ]
|____)-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-
%!PS-Adobe-2.0
%%Title: Datebook - Wallet-sized monthly appointments calendar
%%Creator: B. R. Fowler
%%CreationDate: September 11, 1990
%%DocumentFonts: Helvetica
%%Pages: 1
%%BoundingBox: 0 0 612 792
%%Copyright: Heck, no.  Do what you want with my part of this.
%%EndComments
%
% Plug in the month and year below, as per the examples.  Two datebooks
% will be produced (One page worth), for this month and the one following.
%
% These four lines are the only ones that a casual user need modify:
%
/month 2 def			% E.g., 8 for August
/year 1991 def			% Four digits, as 1990
/name (Bruce Fowler) def	% Top line of id info (cell "0")
/phone ((201)615-5559) def	% Bottom line of id info
%
% The following three functions (isleap, ndays, and startday), and the
% copyright admonition, were borrowed from the calendar.ps code that was
% circulated on the net:
%
% Copyright (C) 1987 by Pipeline Associates, Inc.
% Permission is granted to modify and distribute this free of charge.
%
/isleap {		% is this a leap year?
	year 4 mod 0 eq		% multiple of 4
	year 100 mod 0 ne 	% not century
	year 1000 mod 0 eq or and	% unless it's a millenia
} def
/days_month [ 31 28 31 30 31 30 31 31 30 31 30 31 ] def
/ndays {		% number of days in this month
	days_month month 1 sub get
	month 2 eq	% Feb
	isleap and
	{
		1 add
	} if
} def
/startday {		% starting day-of-week for this month
	/off year 2000 sub def	% offset from start of "epoch"
	off
	off 4 idiv add		% number of leap years
	off 100 idiv sub	% number of centuries
	off 1000 idiv add	% number of millenia
	6 add 7 mod 7 add 	% offset from Jan 1 2000
	/off exch def
	1 1 month 1 sub {
		/idx exch def
		days_month idx 1 sub get
		idx 2 eq
		isleap and
		{
			1 add
		} if
		/off exch off add def
	} for
	off 7 mod		% 0--Sunday, 1--monday, etc.
} def
%
% (End of included calendar.ps code)
%
% This proc makes one month's worth of the calendar (for month, year)
% with the upper left corner at (0,0)
/do_datebook {
	% Draw the identification information in the zeroth cell
	namefont setfont
	4 -12 moveto name show
	4 -24 moveto phone show
	monthfont setfont
	90 -22 moveto monthnames month 1 sub get show
	10 0 rmoveto year dval cvs show
	% Rip through the month, drawing the text for each date
	/offset startday def		% Invoke calculation only once
	1 1 ndays { dup dup	% Do each day of month
		dup 8 idiv hcell mul	% Horizontal position
		exch 8 mod vcell mul	% Vertical position
		gsave translate
			5 -22 moveto	% Position the day number
			dval cvs monthfont setfont show	% (Uses dup value)
			offset add 7 mod	% Day of week (Dup value)
			daynames exch get dup dup
			28 -12 moveto dayfont setfont show
			% Accent saturday/sunday boundary
			(Sa) eq {	% (Uses dup value)
				43 vcell moveto
				10 0 rlineto -5 8 rlineto
				closepath fill
			} if
			(Su) eq {	% (Uses dup value)
				43 0 moveto
				10 0 rlineto -5 -8 rlineto
				closepath fill
			} if
		grestore
	} for
	% Draw the grid that separates the days - from local (0,0)
	0 hcell hsize {		% Vertical lines
		dup 0 moveto vsize lineto
	} for
	0 vcell vsize {		% Horizontal lines
		dup 0 exch moveto hsize exch lineto
	} for
	stroke
} def
% This text is used to label the cells, months and days
/daynames [ (Sa) (Su) (M) (Tu) (W) (Th) (F) ] def
/monthnames [ (Jan) (Feb) (Mar) (Apr) (May) (Jun)
	(Jul) (Aug) (Sep) (Oct) (Nov) (Dec) ] def
/dval 4 string def		% For cvs conversion of year and day numbers
% Define and name the three fonts required
/namefont /Helvetica findfont 9 scalefont def
/dayfont /Helvetica findfont 12 scalefont def
/monthfont /Helvetica findfont 18 scalefont def
% Determine some of the basic parameters of the drawing - These could
% be fine-tuned to match an odd-sized wallet
/hcell 180 def			% Width of a cell
/vcell -31 def			% Height of a cell (Always negative)
/hsize hcell 4 mul def
/vsize vcell 8 mul def
%%EndProlog
%%BeginSetup
% Turn page for landscape mode.  Note that origin is at upper left corner.
% Maybe I have been fooling around with quickdraw for too long !!
[ 0 1 -1 0 0 0 ] concat
%%EndSetup
%%Page: datebook 1
% Position for first of two copies
gsave
	40 -54 translate
	do_datebook
grestore
% Here goes the second of the copies (for the next month)
month 1 add dup /month exch def 12 gt {
	/month 1 def
	/year year 1 add def
} if
gsave
	40 vsize 64 sub translate
	do_datebook
grestore
showpage
%%Trailer