home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1825 < prev    next >
Encoding:
Text File  |  1990-12-28  |  6.7 KB  |  198 lines

  1. Newsgroups: alt.sources
  2. From: brf@cbnewsi.att.com (bruce.r.fowler)
  3. Subject: [postscript] Wallet-sized Datebook Generator
  4. Message-ID: <1990Sep16.004607.17817@math.lsa.umich.edu>
  5. Date: Sun, 16 Sep 90 00:46:07 GMT
  6.  
  7. Archive-name: datebook/11-Sep-90
  8. Original-posting-by: brf@cbnewsi.att.com (bruce.r.fowler)
  9. Original-subject: Wallet-sized Datebook Generator
  10. Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)
  11.  
  12. [Reposted from comp.lang.postscript.
  13. Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).]
  14.  
  15. Dear NetFriends,
  16.  
  17.     Attached is a chunk of PostScript that prints up wallet-sized
  18. appointment calendars for a specified month.  It was inspired by the
  19. recent calendar.ps program and uses some of the same code.
  20.  
  21.     The month is selected by editing the source at line 15 or so.
  22. Trim the results with sissors or papper cutter leaving a small margin
  23. outside the border lines.  Fold in fourths, accordian-style, toward
  24. you on the center vertical line and away from you on the other two.
  25. This results in a 2.5" by 3.5" four-sheet-thick datebook that will
  26. slip easily into your wallet, eliminating the need for that ugly bulge
  27. where you used to have to carry that full-year schedule book.  :-)
  28.  
  29.     You have about .4" by 2" of writing space for each day, so
  30. this is not so good for very busy people, but if you just need to keep
  31. track of dentist appointments or when the next lodge meeting is, this
  32. is for you.  And you can always put extra notes on the back.
  33.  
  34.     BTW, I much enjoy reading this group, and have gotten a lot
  35. of useful information from it.  On the other hand, this is my third
  36. posting in the last six months (the other two being a "lines-not-read"
  37. mod to the Adobe green book error handler, and a game board for "hex").
  38. So far I have gotten zero feedback.  So I am not sure if my articles
  39. are being eaten by the news server, or if people think that this kind
  40. of posting is a waste of bandwith, or if you are all sitting on the
  41. edge of your chairs waiting to see my byline again, or what.  Without
  42. generating too much traffic, maybe one of the regular contributors to
  43. this group could email to let me know that this got out.  Thanks.
  44.  
  45.                               Bruce Fowler
  46.        AT&T HR 2F-027 201-615-5559 Dept 51223 brf@mink.att.com
  47.       +-------------------------------------------------------+
  48.       |  ***   The Twilight Zone - Love it or Leave it.  ***  |
  49.       +-------------------------------------------------------+
  50.  
  51.  ____  ==> [ unzip here ]
  52. |____)-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-
  53. %!PS-Adobe-2.0
  54. %%Title: Datebook - Wallet-sized monthly appointments calendar
  55. %%Creator: B. R. Fowler
  56. %%CreationDate: September 11, 1990
  57. %%DocumentFonts: Helvetica
  58. %%Pages: 1
  59. %%BoundingBox: 0 0 612 792
  60. %%Copyright: Heck, no.  Do what you want with my part of this.
  61. %%EndComments
  62. %
  63. % Plug in the month and year below, as per the examples.  Two datebooks
  64. % will be produced (One page worth), for this month and the one following.
  65. %
  66. % These four lines are the only ones that a casual user need modify:
  67. %
  68. /month 2 def            % E.g., 8 for August
  69. /year 1991 def            % Four digits, as 1990
  70. /name (Bruce Fowler) def    % Top line of id info (cell "0")
  71. /phone ((201)615-5559) def    % Bottom line of id info
  72. %
  73. % The following three functions (isleap, ndays, and startday), and the
  74. % copyright admonition, were borrowed from the calendar.ps code that was
  75. % circulated on the net:
  76. %
  77. % Copyright (C) 1987 by Pipeline Associates, Inc.
  78. % Permission is granted to modify and distribute this free of charge.
  79. %
  80. /isleap {        % is this a leap year?
  81.     year 4 mod 0 eq        % multiple of 4
  82.     year 100 mod 0 ne     % not century
  83.     year 1000 mod 0 eq or and    % unless it's a millenia
  84. } def
  85. /days_month [ 31 28 31 30 31 30 31 31 30 31 30 31 ] def
  86. /ndays {        % number of days in this month
  87.     days_month month 1 sub get
  88.     month 2 eq    % Feb
  89.     isleap and
  90.     {
  91.         1 add
  92.     } if
  93. } def
  94. /startday {        % starting day-of-week for this month
  95.     /off year 2000 sub def    % offset from start of "epoch"
  96.     off
  97.     off 4 idiv add        % number of leap years
  98.     off 100 idiv sub    % number of centuries
  99.     off 1000 idiv add    % number of millenia
  100.     6 add 7 mod 7 add     % offset from Jan 1 2000
  101.     /off exch def
  102.     1 1 month 1 sub {
  103.         /idx exch def
  104.         days_month idx 1 sub get
  105.         idx 2 eq
  106.         isleap and
  107.         {
  108.             1 add
  109.         } if
  110.         /off exch off add def
  111.     } for
  112.     off 7 mod        % 0--Sunday, 1--monday, etc.
  113. } def
  114. %
  115. % (End of included calendar.ps code)
  116. %
  117. % This proc makes one month's worth of the calendar (for month, year)
  118. % with the upper left corner at (0,0)
  119. /do_datebook {
  120.     % Draw the identification information in the zeroth cell
  121.     namefont setfont
  122.     4 -12 moveto name show
  123.     4 -24 moveto phone show
  124.     monthfont setfont
  125.     90 -22 moveto monthnames month 1 sub get show
  126.     10 0 rmoveto year dval cvs show
  127.     % Rip through the month, drawing the text for each date
  128.     /offset startday def        % Invoke calculation only once
  129.     1 1 ndays { dup dup    % Do each day of month
  130.         dup 8 idiv hcell mul    % Horizontal position
  131.         exch 8 mod vcell mul    % Vertical position
  132.         gsave translate
  133.             5 -22 moveto    % Position the day number
  134.             dval cvs monthfont setfont show    % (Uses dup value)
  135.             offset add 7 mod    % Day of week (Dup value)
  136.             daynames exch get dup dup
  137.             28 -12 moveto dayfont setfont show
  138.             % Accent saturday/sunday boundary
  139.             (Sa) eq {    % (Uses dup value)
  140.                 43 vcell moveto
  141.                 10 0 rlineto -5 8 rlineto
  142.                 closepath fill
  143.             } if
  144.             (Su) eq {    % (Uses dup value)
  145.                 43 0 moveto
  146.                 10 0 rlineto -5 -8 rlineto
  147.                 closepath fill
  148.             } if
  149.         grestore
  150.     } for
  151.     % Draw the grid that separates the days - from local (0,0)
  152.     0 hcell hsize {        % Vertical lines
  153.         dup 0 moveto vsize lineto
  154.     } for
  155.     0 vcell vsize {        % Horizontal lines
  156.         dup 0 exch moveto hsize exch lineto
  157.     } for
  158.     stroke
  159. } def
  160. % This text is used to label the cells, months and days
  161. /daynames [ (Sa) (Su) (M) (Tu) (W) (Th) (F) ] def
  162. /monthnames [ (Jan) (Feb) (Mar) (Apr) (May) (Jun)
  163.     (Jul) (Aug) (Sep) (Oct) (Nov) (Dec) ] def
  164. /dval 4 string def        % For cvs conversion of year and day numbers
  165. % Define and name the three fonts required
  166. /namefont /Helvetica findfont 9 scalefont def
  167. /dayfont /Helvetica findfont 12 scalefont def
  168. /monthfont /Helvetica findfont 18 scalefont def
  169. % Determine some of the basic parameters of the drawing - These could
  170. % be fine-tuned to match an odd-sized wallet
  171. /hcell 180 def            % Width of a cell
  172. /vcell -31 def            % Height of a cell (Always negative)
  173. /hsize hcell 4 mul def
  174. /vsize vcell 8 mul def
  175. %%EndProlog
  176. %%BeginSetup
  177. % Turn page for landscape mode.  Note that origin is at upper left corner.
  178. % Maybe I have been fooling around with quickdraw for too long !!
  179. [ 0 1 -1 0 0 0 ] concat
  180. %%EndSetup
  181. %%Page: datebook 1
  182. % Position for first of two copies
  183. gsave
  184.     40 -54 translate
  185.     do_datebook
  186. grestore
  187. % Here goes the second of the copies (for the next month)
  188. month 1 add dup /month exch def 12 gt {
  189.     /month 1 def
  190.     /year year 1 add def
  191. } if
  192. gsave
  193.     40 vsize 64 sub translate
  194.     do_datebook
  195. grestore
  196. showpage
  197. %%Trailer
  198.