Thread View: comp.lang.postscript
1 messages
1 total messages
Started by adamstr
Fri, 16 Oct 1992 22:04
Need help with zip-code bar-code pgm.
Author: adamstr
Date: Fri, 16 Oct 1992 22:04
Date: Fri, 16 Oct 1992 22:04
200 lines
7584 bytes
7584 bytes
Hello - I recently received the following US Postal Barcode generator
program from my system manager, who found it on the net (not sure when).
I have been inserting various zip codes in the
parenthesis just previous to the first "dobar" command at the bottom of the
file. I have been viewing the results thru both the "CDA VIEWER" application on
my VAXStation 3100 and on paper from our DEC Printserver 20. I am running
across something that is really confusing - it seems to dislike my own zip
code! (840587675)
Here is the error as it appears thru the CDA VIEWER:
%%[Error:rangecheck;Offending Command:get]%%
Here is the error as it appears on paper:
%LPS-W-RANGECHK, rangecheck: Argument out of bounds - offending command
is get
I can't figure out why it seems to work on some zip codes, but not on others.
Any suggestions will be appreciated!! - the entire program follows.
-----------------------------------------------------------------------
%
%
% (C) Copyright 1990 by Woody Baker
% Rt.1 Box I
% Manor, Tx. 78653
%
% this code may be used for personal use, as long as this header
% remains intact but may not be used
% as part of a commercial package. All commercial rights reserved.
%
%
% code to print usps barcode.
% checkdigit computation is the sum of the digits, rounded up to
% the next even multiple of 10.
%
% You MUST print this on the envelope within certain very specific areas.
% The x and y coordinate MUST have the following relationship with the
% RIGHT LOWER CORNER of the envelope.
% x can be no further from the right edge than 4" and no closer than
% 3 1/4. The y coordinate MUST be 1/4 inch up from the bottom of the
% envelope, +/- 1/16 th inch. The x coordinates' wide lea-way is
% to accomodate shifting of inserts containing POSTNET codes which appear
% through windows in the envelope. For printed barcodes on envelopes
% the post office prefers 3 7/8 to 4 inches.
% request Publication 25 (A Guide to Business Mail Preparation) from
% your local Post Office. Be sure to ask for the template that accompanies
% the book.
%
/inches {72 mul} def
/barwidth .020 inches def % MUST NOT CHANGE
/long .125 inches def % MUST NOT CHANGE
/short .050 inches def % MUST NOT CHANGE
/nextx .0475 inches def % MUST NOT CHANGE
%
% one of the recommended fonts for OCR lables. 10/14 is one of the
% recommended settings.
%
/Helvetica findfont 10 scalefont setfont
/linehite 14 def
%
/digarray
[
{
lbar lbar sbar sbar sbar % digit 0
}
{
sbar sbar sbar lbar lbar % digit 0
}
{
sbar sbar lbar sbar lbar % digit 2
}
{
sbar sbar lbar lbar sbar % digit 3
}
{
sbar lbar sbar sbar lbar % digit 4
}
{
sbar lbar sbar lbar sbar % digit 5
}
{
sbar lbar lbar sbar sbar % digit 6
}
{
lbar sbar sbar sbar lbar % digit 7
}
{
lbar sbar sbar lbar sbar % digit 8
}
{
lbar sbar lbar sbar sbar % digit 9
}
] def
%
% sbar does a short bar, and alters the current point accordingly
%
%
/sbar
{
barwidth setlinewidth % always make sure it is correct width
currentpoint % remember where we are
currentpoint short add lineto % do the bar
exch nextx add exch moveto % advance the current point
} def
%
% lbar does a tall bar and alters the current point accordingly
%
/lbar
{
barwidth setlinewidth % always make sure it is correct width
currentpoint % remember where we are
currentpoint long add lineto % do the bar
exch nextx add exch moveto % advance the current point
} def
%
% routine takes a string of numbers (no hyphens in the first cut)
% an orientation flag (1=Landscape) and an x and y coordinate
%
%
% x y orientation (numberstring)
%
% check digit computation 10 sum 10 mod sub computes the remainder
% from a divide by 10, and then subtracts that from 10 to generate
% a digit, which if added back to sum would round it up to the next even
% multiple of 10
%
/dobar
{
/msg exch def % get all parameters from the stack.
/orient exch def
moveto % relative to origin of mail piece
/sum 0 def
gsave
orient 1 eq
{
90 rotate 0 -612 translate
} if
lbar % starting marker
msg % process the message.
{
48 sub dup % convert the digit to binary
sum add /sum exch def % update the checksum
/digval exch def % have the binary digit
digarray digval get exec % draw the digit.
}
forall
digarray
10 sum 10 mod sub % compute check digit
get exec
lbar % ending marker
stroke
grestore
} def
%
% routine takes x y array of strings and does an address block
% for an envelope. Prefered is ALL UPPERCASE
% [(WOODY BAKER) (RR 1 BOX I) (MANOR TX 78653)]
% NOTE: the City State and Zip MUST be the last line, and in that order.
% it is preferable NOT to use punctuation. If the last line won't fit, it
% is permitted to put the ZIPCODE on the line under that, all by itself.
% you should provide that decision, when constructing the array of strings.
%
% In addition, since this is HELVETICA, and it is Proportional, it
% is a wise idea to put 2 spaces down rather than 1 for separation. The
% USPS states that there should be at least 1 full space or 1 em space
% between the characters, and at least 2 points additional
% leading between the lines, 4 points is better for a 10 pt font.
%
% bottom line of RETURN address no lower that 2 3/4" from bottom edge
% of envelope. Mailto address should fit within a rectangle that extends
% from 5/8 " from the bottom, to 2 1/4" up from the bottom of the mail piece.
%
/address
{
/stringaray exch def
/ycoord exch def
/xcoord exch def
xcoord
stringaray length % get number of lines
linehite mul ycoord add moveto % adaptively find the top line.
stringaray
{
currentpoint linehite sub exch pop xcoord exch moveto
show
} forall
} def
%
% example code for testing
%
100 120 [(WOODY BAKER) (RR 1 BOX I) (MANOR TX 78653-0102)] address
100 100 0 (786530102) dobar
200 200 1 (1234567890) dobar
showpage
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads