Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!eleni.gc.cuny.edu!timessqr.gc.cuny.edu!cunyvms1.gc.cuny.edu!DLV From: dlv@cunyvms1.gc.cuny.edu (Dimitri Vulis, CUNY GC Math) Newsgroups: comp.text.tex Subject: Re: LaTeX macros for POSTNET and FIM bar codes on envelopes Message-ID: <1991Mar6.180803.23787@timessqr.gc.cuny.edu> Date: 6 Mar 91 18:08:03 GMT References: <00944e15.cdff08a0.5442@CUNYVMS1.GC.CUNY.EDU> Sender: news@timessqr.gc.cuny.edu (USENET News System) Reply-To: dlv@cunyvms1.gc.cuny.edu Organization: Graduate School and University Center, C.U.N.Y. New York NY 10036 Lines: 195 Burton Randol pointed out to me the following glitch in the Postnet macros I posted a few days ago. The old code said: \ifx#1\empty\else% \ZipBar{} This was really a bug!!! :) I added this at the last moment because without checking for an empty argument \ZipBar{} produced frame bars and a single checksum digit (0). But of course I meant: \gdef\zipcode{#1}% \ifx\zipcode\empty\else% Shame on me!!! :) Anyway, I've fixed this and I made a couple of other cosmetic changes, so I'm re-posting the corrected macros. Please discard the old ones. Sorry!! Dimitri Vulis ---- env.sty % Copyright 1988, 1991 by Dimitri Vulis. % All rights reserved. \newbox\PostNetBox \newbox\ZipBarL \newbox\ZipBarS \setbox\ZipBarL\hbox{\vrule \@height.125in \@width.020in\hskip.0276in} \setbox\ZipBarS\hbox{\vrule \@height.05in \@width.020in\hskip.0276in} %counters used to compute the checksum \newcount\ZipBarm \newcount\ZipBarn \chardef\ten=10 \def\ZipBar@@@#1#2{% \expandafter\def\csname ZipBar@@#1\endcsname% {#2\advance\ZipBarn#1\relax}} \ZipBar@@@0{\copy\ZipBarL\copy\ZipBarL% \copy\ZipBarS\copy\ZipBarS\copy\ZipBarS} \ZipBar@@@1{\copy\ZipBarS\copy\ZipBarS% \copy\ZipBarS\copy\ZipBarL\copy\ZipBarL} \ZipBar@@@2{\copy\ZipBarS\copy\ZipBarS% \copy\ZipBarL\copy\ZipBarS\copy\ZipBarL} \ZipBar@@@3{\copy\ZipBarS\copy\ZipBarS% \copy\ZipBarL\copy\ZipBarL\copy\ZipBarS} \ZipBar@@@4{\copy\ZipBarS\copy\ZipBarL% \copy\ZipBarS\copy\ZipBarS\copy\ZipBarL} \ZipBar@@@5{\copy\ZipBarS\copy\ZipBarL% \copy\ZipBarS\copy\ZipBarL\copy\ZipBarS} \ZipBar@@@6{\copy\ZipBarS\copy\ZipBarL% \copy\ZipBarL\copy\ZipBarS\copy\ZipBarS} \ZipBar@@@7{\copy\ZipBarL\copy\ZipBarS% \copy\ZipBarS\copy\ZipBarS\copy\ZipBarL} \ZipBar@@@8{\copy\ZipBarL\copy\ZipBarS% \copy\ZipBarS\copy\ZipBarL\copy\ZipBarS} \ZipBar@@@9{\copy\ZipBarL\copy\ZipBarS% \copy\ZipBarL\copy\ZipBarS\copy\ZipBarS} \def\ZipBar@@#1{\csname ZipBar@@#1\endcsname} \def\ZipBar@#1{% \ifx#1\null% \let\next\relax% \else% \ZipBar@@{#1}% \let\next\ZipBar@% \fi% \next} \def\ZipBar#1{% \gdef\zipcode{#1}% \ifx\zipcode\empty\else% \@FIMAtrue% \setbox\PostNetBox\hbox{% \copy\ZipBarL% start with a frame bar \ZipBarn\z@% \ZipBar@#1\null% \ZipBarm\ZipBarn% \divide\ZipBarm\ten% \multiply\ZipBarm\ten% \advance\ZipBarm-\ZipBarn% \ifnum\ZipBarm<0% \advance\ZipBarm\ten% \fi% \ZipBar@@{\the\ZipBarm}% correction digit \copy\ZipBarL% end with a frame bar }% \fi% if empty } \newbox\FIMAbox \setbox\FIMAbox\vbox{% \hrule\@height.625in\@width.031in} \setbox\FIMAbox\hbox{\copy\FIMAbox \hskip.0315in\copy\FIMAbox\hskip.1565in% \copy\FIMAbox\hskip.1565in% \copy\FIMAbox\hskip.0315in\copy\FIMAbox} \newif\if@FIMA \newbox\AddressBox \newbox\FromBox \setbox\FromBox\null % font used for printing the address \let\addressfont\twlsf \def\EnvMakeBox#1#2{ \setbox#1\vbox{ \parindent0pt \leftskip0pt \lineskip1pt \baselineskip14pt \rightskip\@flushglue \addressfont #2} } \def\envaddress#1{\EnvMakeBox\AddressBox{#1}} \def\from#1{\EnvMakeBox\FromBox{#1}} \def\envelope{ \@FIMAfalse \gdef\zipcode{\empty} \setbox\PostNetBox\null \setbox\AddressBox\null } \def\endenvelope{ \newpage \if@FIMA \vbox to 0pt{ \hbox to \hsize{\hfill \copy\FIMAbox\hskip2in} \vss} \fi % These magic numbers are for my stationery \vbox{\vskip.435in\hbox{\hskip.32in\copy\FromBox}} \vfill \vbox to0pt{\vss % Address is 1 inch from the left % and 1 inch from the bottom \hbox{\hskip1in\box\AddressBox} \vskip.375in} \vbox to .625in{ \vfill \hbox to \hsize{ \hfill \hbox to 3.875in{ \unhbox\PostNetBox\hfill}} \vskip.25in }} ---- env.tex (example of using it) \documentstyle[env]{article} \nofiles \textwidth9.5in \textheight4.125in \pagestyle{empty} \begin{document} \from{Dimitri Vulis} \begin{envelope} \ZipBar{10036-8099} \envaddress{ Dimitri Vulis\\ Department of Mathematics/Box 330\\ Graduate School \& University Center\\ City University of New York\\ 33 West 42 Street\\ New York, New York\quad\zipcode % or only: %New York, New York\quad10036 } \end{envelope} \end{document} Dimitri Vulis, D&M BITNET: DLV@CUNYVMS1 Internet: DLV@CUNYVMS1.GC.CUNY.EDU Snail: Department of Mathematics/Box 330 City Univesrity of New York Graduate Center 33 West 42 Street New York, NY 10036-8099 USA