[comp.lang.postscript] Template Generator for IBM Enhanced Keyboard

leggedav@nic.cerf.net (David Legge) (04/18/91)

{Here is a PostScript routine to print 4 keyboard templates per 8.5" X 11"
page.  Compatible with 101 key IBM enhanced keyboards.

------------ CUT -------- CUT --------- CUT ----------------
%%!PS-Adobe-1.0
%
% template.ps
% Print an IBM PC/XT/AT Enhanced Keyboard template.
% 
% This code will print 4 keyboard templates per page
% for keyboards that have 12 function keys in groups of 
% four along the top of the keyboard.
%
% To use: Define the TITLE and fill in each of the 4
% arrays fkey (Function Key Only), skey (Shift Function Key),
% akey (Alt Function Key), and ckey (Ctrl Function Key).
%
% NOTE: be sure to leave all 13 elements of each array defined.
%
% This code may be used freely and without compensation to the
% author for personal and private use. 
% This code may not be included in any program for which a fee is 
% charged without the express written permission of the author.
%
%                       (c) 1991 Data Services
%                          P.O. Box 901906
%                  Palmdale, California  93590-1906
%                         leggedav@cerf.net
%
%-----------------------------------------------------
% Define the variables
%-----------------------------------------------------
/LM .25 def		% Right Margin
/BM .25  def		% Bottom Margin
/b1strt  .6375 def	% Box #1 start
/b2strt 4.0125 def	% Box #2 start
/b3strt 7.3875 def	% Box #3 start
/txtstartln .31736 def  % Starting position of text bottom line
/keysperbox 4 def	% # of keys to each box
/boxlen     3 def     	% Lenhgth of each box
/boxdist  b2strt boxlen sub b1strt sub def % Distance from end of box to next
/TITLE (Title:) def
%------------------------------------------------------
% Function Key Only Text F1 -> F12 all must be defined
%------------------------------------------------------
/fkey [(     F1     ) (     F2     ) (     F3     ) (     F4     )
       (     F5     ) (     F6     ) (     F7     ) (     F8     ) 
       (     F9     ) (     F10    ) (     F11    ) (     F12    )
       (Key)] def
%------------------------------------------------------
% Shift Function Key
%------------------------------------------------------
/skey [(     F1     ) (     F2     ) (     F3     ) (     F4     )
       (     F5     ) (     F6     ) (     F7     ) (     F8     ) 
       (     F9     ) (     F10    ) (     F11    ) (     F12    )
       (Shift)] def
%------------------------------------------------------
% Alt Function Key
%------------------------------------------------------
/akey [(     F1     ) (     F2     ) (     F3     ) (     F4     )
       (     F5     ) (     F6     ) (     F7     ) (     F8     ) 
       (     F9     ) (     F10    ) (     F11    ) (     F12    )
       (Alt)] def
%------------------------------------------------------
% Ctrl Function Key
%------------------------------------------------------
/ckey [(     F1     ) (     F2     ) (     F3     ) (     F4     )
       (     F5     ) (     F6     ) (     F7     ) (     F8     ) 
       (     F9     ) (     F10    ) (     F11    ) (     F12    )
       (Ctrl)] def
%------------------------------------------------------
% Define the Procedures
% -----------------------------------------------------
/I {72 mul} def
/B {newpath
     moveto 
     0  .75 I  rlineto
     boxlen I  0    rlineto
     0 -.75  I rlineto
      closepath
    stroke } def
/S {newpath
    moveto
    10.5 I 0 rlineto
    11 setlinewidth
    .995 setgray
    stroke } def    
/TXTPRT {ptr get dup
         curx I cury I moveto show
         /curx curx .75 add def			% Incrament x pointer
         /ptr ptr 1 add def 			% Add 1 to array pointer
         ptr keysperbox mod 0 eq                % Check if at the end of a box
         {/curx curx boxdist add def} if        % Skip to next box
         ptr 12 eq 				% Look for key label 
         {/curx curx boxdist sub def} if } def  % do not skip for last item
%--------------------------------------------------------------
% Draw the outside box and outlines for the keys
%--------------------------------------------------------------
/BOX {
  newpath
  LM I BM I moveto
  0 1.688 I rlineto
  10.5 I 0 rlineto
  0 -1.688 I rlineto closepath
  1 setlinewidth
  stroke 
  b1strt I .9375 I B
  b2strt I .9375 I B 
  b3strt I .9375 I B
  LM I .50625 I S
  LM I .81875 I S
  0 setgray } def
%-------------------------------------------------------------
%Print the text
%-------------------------------------------------------------
/TEXT {
  /Courier findfont 7 scalefont setfont
  /curx b1strt def
  /cury txtstartln def
  /ptr  0 def
  13 {ckey TXTPRT} repeat
  /curx b1strt def
  /cury txtstartln .15 add def
  /ptr  0 def
  13 {akey TXTPRT} repeat
  /curx b1strt def
  /cury txtstartln .30 add def
  /ptr  0 def
  13 {skey TXTPRT} repeat
  /curx b1strt def
  /cury txtstartln .45 add def
  /ptr  0 def
  13 {fkey TXTPRT} repeat
  b1strt I 1.8 I moveto
  TITLE show
} def
%--------------------------------------------------------------
% Set-up the page
%--------------------------------------------------------------
2.5 I 0 translate
90 rotate
4 {
  BOX
  TEXT
  0 -2 I translate } repeat
showpage

------------ END -------- END --------- END ----------------

..........................................................................
David Legge leggedav@cerf.net

Expires: 17/05/91


Sender: 
Followup-To: 
Distribution: 
Organization: CERFnet, La Jolla, CA
Keywords: PostScript Template Keyboard