Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!decwrl!mogul From: mogul@decwrl.dec.com (Jeffrey Mogul) Newsgroups: comp.lang.postscript Subject: Re: PostScript Calendars redux (and improved source) Keywords: calendars annotations Message-ID: <254@jove.dec.com> Date: 8 Jan 90 23:33:35 GMT References: <1739@lzga.ATT.COM> <2816@dciem.dciem.dnd.ca> Organization: DEC Western Research Lines: 711 In article <2816@dciem.dciem.dnd.ca> tim@dretor.dciem.dnd.ca (Tim Pointing) writes: >In a recent posting, an updated "pscal" was posted. I found one small >"bug" (where the program didn't behave as the comments suggested.) >The change is in line 93... change > > -*) echo "$USAGE" 1>&2; exit 1;; > >to > > -*) eval ENVAR=$1; shift 1;; This is close, but not quite right, since it doesn't allow you to specify more than one such passed-through argument. The original program also had a bug in the "-R" mode; it would rotate the calendar completely off the page. I fixed this and also made -R scale the image so as to fit on an 8.5x11 sheet of paper. Finally, I wrote a short manual page. The new source and the manual page are appended to the end of this message, in "shar" format. -Jeff #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'pscal.sh' <<'END_OF_FILE' X#!/bin/sh X#+ X# X# NAME: X# pscal X# X# SYNOPSIS: X# pscal [-Pprinter] [other printer flags] month year X# X# DESCRIPTION: X# `Pscal' is a PostScript program to print calendars. X# X# The file $HOME/.holiday is read and used to print short messages X# on specified days. The .holiday file should consist of lines of X# the form X# month:day:message string X# Messages should be 20 characters or less, with no more than 6 X# messages per day. No spaces should appear from the beginning X# of a line until after the second colon. X# Month and day should be numbers in the obvious ranges. X# 12/89 - The holiday checking has been loosened up in that the X# following takes place: X# 1. The Shell Variable EFILE is used preferentially X# 2. Then the file Events in the current directory is used X# 3. Finally the $HOME/.holiday file is used. X# The whole process can be turned off by setting EFILE=/dev/null. X# X# OPTIONS: X# Any argument whose first character is '-' is passed on to lpr. X# The shell variables BANNER, LFOOT, CFOOT, and RFOOT become a X# top centered banner, and left, centered, or right justified X# footers respectively. As in: X# X# BANNER="Schedule 1" CFOOT=Preliminary pscal 4 90 X# X# AUTHOR: X# Patrick Wood X# Copyright (C) 1987 by Pipeline Associates, Inc. X# Permission is granted to modify and distribute this free of charge. X# X# HISTORY: X# @Original From: patwood@unirot.UUCP (Patrick Wood) X# @Shell stuff added 3/9/87 by King Ables X# @Made pretty by tjt 1988 X# @Holiday and printer flag passing hacks added Dec 1988 X# @ by smann@june.cs.washington.edu X# @Used the better looking version with 5 rows of days rather than 6 X# @ hacked together with holiday and banner/footnotes added X# @ by Joe (No Relation) Wood, 12/89, jlw@lzga.ATT.COM X# @Fixed "-R" (didn't work at all; now it at least works on 8.5x11) X# @Also fixed handling of unrecognized arguments X# @ by Jeff Mogul, 1/90, mogul@decwrl.dec.com X# X# BUGS: X# `Pscal' doesn't work for months before 1753 (weird stuff happened X# in September, 1752). X# X# A better format for the dates of holidays would be nice. X# An escape to allow holiday messages to be raw PostScript would X# also be nice. X# The holiday messages should be handled more intelligently (ie, X# the messages should be clipped to the day). X# X X# X# PostScript program to print calendars. X# Doesn't deal well with September 1752 or before. X# X USAGE="Usage: pscal [ -Rrt ] [ -F hfont ] [ -f font ] [ month [ year ] ]" X TFONT=Times-Bold DFONT=Helvetica-Bold XEFONT=Times-Roman X ROTATE=90 SCALE="1.0 1.0" TRANSLATE="50 -120" X LPR="lpr" X while test $# != 0 do X case $1 in X -P) test $# -lt 2 && { echo "$USAGE" 1>&2; exit 1; } X eval ENVAR="$1$2"; shift 2;; X -P*) eval ENVAR=$1; shift 1;; X -F) test $# -lt 2 && { echo "$USAGE" 1>&2; exit 1; } X TFONT="$2"; shift 2;; X -F*) TFONT=`echo $1 | sed -n 1s/-.//p`; shift 1;; X -f) test $# -lt 2 && { echo "$USAGE" 1>&2; exit 1; } X DFONT="$2"; shift 2;; X -f*) DFONT=`echo $1 | sed -n 1s/-.//p`; shift 1;; X -t) LPR=cat; shift 1;; X -r) ROTATE=90; shift 1;; X -R) ROTATE=0; SCALE="0.75 0.75"; TRANSLATE="50 900"; shift 1;; X --|-) break;; X -*) eval ENVAR=\"$ENVAR $1\"; shift 1;; X *) break X esac done X test $# -gt 2 && { echo "$USAGE" 1>&2; exit 1; } X case $# in X 0) set `date`; YEAR=$6 X MONTH=`case $2 in Jan) echo 1;;Feb) echo 2;;Mar) echo 3;;Apr) echo 4;; X May) echo 5;;Jun) echo 6;;Jul) echo 7;;Aug) echo 8;; X Sep) echo 9;;Oct) echo 10;;Nov) echo 11;;Dec) echo 12;;esac`;; X 1) MONTH=$1; set `date`; YEAR=$6;; X 2) MONTH=$1 YEAR=$2;; esac X if [ -n "$EFILE" -a -r "$EFILE" ] then X Files=$EFILE elif [ -r Events ] then X Files=Events elif [ -r $HOME/.holiday ] then X Files=$HOME/.holiday else X Files=/dev/null fi X holidays=`cat $Files | grep \^$MONTH: | awk -F: '{printf("%s ( %s",$2,$3);\ X for(i = 4; i <= NF; i++) printf(":%s", $i);printf(")\n"); }'` X test $YEAR -lt 100 && YEAR=`expr $YEAR + 1900` X X$LPR $ENVAR <'pscal.man' <<'END_OF_FILE' X.TH PSCAL L X.SH NAME pscal \- print calendar page on a PostScript printer X.SH SYNTAX X.B pscal X[ -Pprinter ] X[ -R ] [ -r ] [ -t ] X[ month [ year ] ] X.SH DESCRIPTION X.I Pscal prints (on a PostScript printer) a calendar for the specified month and year. The year, if omitted, defaults to the current year. If both month and year are omitted, the current month is printed. X.I Year can be between 1753 and 9999. The X.I month is a number between 1 and 12. X.PP This version of the X.I pscal program will print short messages on user-chosen dates, as specified in your X.I $HOME/.holiday file. The .holiday file should consist of lines of the form X.nf X.RS month:day:message string X.RE X.fi Messages should be 20 characters or less, with no more than 6 messages per day. No spaces should appear from the beginning of a line until after the second colon. Month and day should be numbers in the obvious ranges. XFor example, X.nf X.RS X12:16:Beethoven's Birthday X.RE X.fi X.SH OPTIONS X.IP "\-P\fIprinter\fR" 1i The printer may be specified with the usual \-P\fIprinter\fR syntax. X.IP "\-r" 1i The calendar page is printed in ``landscape'' orientation (the default). X.IP "\-R" 1i The calendar page is printed in ``portrait'' orientation; this yields a slightly smaller image and may be more suitable for embedding into other documents. X.IP "\-t" 1i Causes the PostScript to be sent to the standard output, rather than to the printer. This is useful if you wish to save the output in a file, or if you want to use options with the X.IR lpr (1) command. X.IP "\-F\fIfont\fR" 1i Sets the font family for the title text (the month and year). X.IP "\-f\fIfont\fR" 1i Sets the font family for the day-of-month numbers. X.PP Other arguments starting with `\-' are passed through to X.IR lpr (1). X.SH FILES X$HOME/.holiday END_OF_FILE if test 1794 -ne `wc -c <'pscal.man'`; then echo shar: \"'pscal.man'\" unpacked with wrong size! fi # end of 'pscal.man' fi echo shar: End of shell archive. exit 0