% \CheckSum{541}
% \iffalse
% ====================================================================
%% adrguide.dtx
%% Copyright 2006, 2010 Axel Kielhorn
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
% 
% This Current Maintainer of this work is Axel Kielhorn (A.Kielhorn@web.de)
%
% This work consists of the files adrconv.ins, adrconv.dtx, adrguide.tex
% and the derived file adrguide.pdf. 
%
% Use
%   tex adrconv.ins
% or
%   latex adrconv.ins
% to generate the other files, which are indirect parts of the
% bundle. Use
%   latex adrconv.dtx
% to generate the implementation documentation. Use
%   latex adrguide.tex
% to generate the user documentation.
%
% ====================================================================
%
%<*dtx>
\ProvidesFile{adrconv.dtx}
%</dtx>
%<driver>\ProvidesFile{adrconv.drv}
%<guide>\ProvidesFile{adrguide.tex}
%<*tex|cfg|dir|montage>
%<tex|cfg|dir|montage>\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
%<tex|cfg|dir|montage>\ProvidesFile{%
%<conv>  adrconv%
%<fax>   adrfax%
%<dir>   adrdir%
%<birthday>  adrbirthday%
%<planer>  adrplaner
%<small>  adrsmall
%<montage&erster> adrmontage1.tex
%<montage&zweiter> adrmontage2.tex
%<tex>  .tex%
%<dir&!cfg>  .tex%
%<cfg>  .cfg%
%<tex|cfg|dir|montage>  }
%</tex|cfg|dir|montage>
%<*dtx|driver|guide|tex|cfg|dir>
  [2010/04/02 v1.3 LaTeX2e
%<*dtx>
  adrconv docstrip file]
%</dtx>
%<driver> adrconv implementation documentation driver]
%<guide>  Address guide]
%<tex>  Interactive driver of BibTeX database to addressfile converter]
%<cfg>  adrconv configuration file]
%<dir&!cfg>  Interactive address directory generation]
%</dtx|driver|guide|tex|cfg|dir>
%<*driver>
\documentclass{ltxdoc}
\CodelineIndex
\RecordChanges

\newcommand*{\Class}[1]{\textsf{#1}}
\newcommand*{\Package}[1]{\textsf{#1}}
\newcommand*{\File}[1]{\texttt{#1}}

\ifx\KOMAScipt\undefined
  \DeclareRobustCommand{\KOMAScript}{\textsf{K\kern.05em O\kern.05em%
      M\kern.05em A\kern.1em-\kern.1em Script}}
\fi

\makeatletter
\DeclareRobustCommand{\BibTeX}{B\kern-.05em%
  % Der folgende Hack stammt aus der Definition des
  % Makros \LaTeX, siehe Datei `ltlogos.dtx' der
  % LaTeX2e-Verteilung.
  \hbox{$\m@th$% %% force math size calculations
    \csname S@\f@size\endcsname \fontsize\sf@size\z@
    \math@fontsfalse\selectfont
    I\kern-.025emB}%
  \kern-.08em%
  \-\TeX%
}
\makeatother

\begin{document}
  \DocInput{adrconv.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{adrconv.dtx}
% \title{\BibTeX{} address database to addressfile
%   converter\footnote{This file has version number \fileversion, last
%     revised \filedate}}
% \author{Axel Kielhorn\thanks{A.Kielhorn@web.de} \and Markus Kohm}
% \date{\filedate}
% \maketitle
% \begin{abstract}
% \Package{adrconv} is an example for converting \BibTeX{} address
% databases to \KOMAScript{} address files. For more information see
% the ``ADRconv Anleitung''. This is only the implementation
% documentation.
% \end{abstract}
%
% \StopEventually{\PrintIndex\PrintChanges}
%
% \tableofcontents
%
% \section{General}
%
% This implementation documentation is very rudimentary because it was
% not written by Axel Kielhorn but by Markus Kohm. I've done this
% because after two years waiting I wanted to make the break and
% remove the old version of \Package{adrconv} from \KOMAScript.
%
% The use of \Package{adrconv} is described at the ``ADRconv
% Anleitung''. You'll get the guide, running \TeX{} or \LaTeX{} in
% \File{adrconv.ins}.
%
%
% \section{The interactive drivers}
%
% \iffalse
%<*tex>
% \fi
% Remember the files should work not only with \LaTeX{} but also with
% Plain\TeX. So we can olny use macros, which are defined at both:
% \LaTeX{} and Plain\TeX.
%
%    \begin{macrocode}
\catcode`\@=11
\newlinechar`\^^J
\message{%
  Now you have to typein the name of the BibTeX addressfile, you want
  to^^J%
  convert to script-address-file-format (without extension
  `.bib'):^^J%
  Geben Sie nun den Namen der BibTeX-Adressdatei ein, die sie in
  das^^J%
  Script-Adressdateiformat konvertieren wollen (ohne `.bib'):^^J%
  ^^J%
  addressfile=%
}
\def\skiplastspace#1 \@e@o@l@{#1}
\read-1 to \addressfile
\edef\addressfile{\expandafter\skiplastspace\addressfile\@e@o@l@}
\newwrite\auxfile
\immediate\openout\auxfile=\addressfile.aux
\immediate\write\auxfile{%
  \string\citation{*}^^J%
%<conv>  \string\bibstyle{adrconv}^^J%
%<fax>  \string\bibstyle{adrfax}^^J%
%<birthday>  \string\bibstyle{adrbirthday}^^J%
  \string\bibdata{\addressfile}%
}
\immediate\closeout\auxfile
\message{%
  After running BibTeX rename file `\addressfile.bbl' to
  `\addressfile.adr'!^^J%
  Nach dem BibTeX-Lauf benennen Sie bitte die Datei `\addressfile.bbl'
  in^^J%
  `\addressfile.adr' um!^^J%
}
\ifx\@@end\undefined\let\@@end\end\fi
\@@end
%    \end{macrocode}
% \iffalse
%</tex>
% \fi
%
%
% \section{The interactive generator}
%
% \iffalse
%<*!cfg>
%<*dir>
% \fi
%    \begin{macrocode}
\documentclass[headsepline,10pt,twoside,pagesize]{scrartcl}
%    \end{macrocode}
% Define some new commands
%    \begin{macrocode}
\newcommand*\jj {j}
\newcommand*\ja {ja}
\newcommand*\y  {y}
\newcommand*\yes{yes}
\newread\ttyin
\newcommand*{\gobble}[1]{}
\def\iden#1{#1}
\def\strip#1#2 \gobble{\def #1{#2}}
\def\defpar{\par}
\def\Ask#1#2{%
    \message{#2}\read\ttyin to #1\ifx#1\defpar\def#1{}\else
    \iden{\expandafter\strip\expandafter#1#1\gobble\gobble}
    \gobble\fi}
%    \end{macrocode}
% \cs{ifGerman} to load \Package{german} or \Package{ngerman}.
% \cs{RunningHead} to get the names in the header (Telephonebook
% style). Otherwise a new page is started for each new letter (This is
% needed for Birthday lists). 
%    \begin{macrocode}
\newif\ifGerman
\newif\ifRunningHead
\newif\ifEmail
%    \end{macrocode}
%    \begin{macrocode}
\newdimen\leftfield
\newdimen\rightfield
\newdimen\adrindent
\oddsidemargin  -1in
\evensidemargin -1in
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\adrfile{}
\newcommand*\adrtitle{}
\typeout{^^J%
   *** dir.tex v2.0 by Frank Neukam <01 Dec 1993>^^J%
   *** LaTeX2e-changes by Markus Kohm 1994/10/29^^J%
   *** ADRconv-changes by Axel Kielhorn 1999^^J%
   *** ngerman-changes by Markus Kohm 2001^^J%
   ^^J%
   To create a address-directory just answer the questions:^^J%
   ^^J}
\Ask\answer{Use german? [y/n]^^J%
  Mit deutscher Sprachanpassung? [j/n]}
\ifx\jj\answer\Germantrue\else
\ifx\ja\answer\Germantrue\else
\ifx\y\answer\Germantrue\else
\ifx\yes\answer\Germantrue\else
                \Germanfalse\fi\fi\fi\fi
\ifGerman
  \def\germanpackage{ngerman}
  \Ask\answer{Mit alter deutscher Rechtschreibung? [j/n]}
  \ifx\jj\answer\def\germanpackage{german}\else
    \ifx\ja\answer\def\germanpackage{german}\else
      \ifx\y\answer\def\germanpackage{german}\else
        \ifx\yes\answer\def\germanpackage{german}\fi\fi\fi\fi
     \usepackage{\germanpackage}
\fi
%    \end{macrocode}
% \changes{v1.3}{2010/04/02}{Added support to print the e-mail Address in the addressbook.}
%    \begin{macrocode}
\Ask\answer{^^JPrint email? [y/n]^^J%
  E-Mail ausgeben? [j/n]}
\ifx\jj\answer\Emailtrue\else
\ifx\ja\answer\Emailtrue\else
\ifx\y\answer\Emailtrue\else
\ifx\yes\answer\Emailtrue\else
                \Emailfalse\fi\fi\fi\fi
\ifEmail
\usepackage{url}
\fi
\InputIfFileExists{dir.cfg}{%
  \typeout{Load local configuration-file.}}{%
  \typeout{No local configuration-file found.}}
\Ask\adrfile{^^J%
  Name of address-file (without .adr)?^^J%
  Name der Adressdatei (ohne .adr)?}
\Ask\adrtitle{^^J%
  Title of directory/list?^^J%
  Titel des Verzeichnisses?}
\Ask\adrformat{^^J%
  Name of the layout^^J%
  Layoutname?}
\Ask\answer{^^J%
  With running head? [y/n]^^J%
  Namen in der Kopfzeile? [j/n]}
\ifx\jj\answer\RunningHeadtrue\else
\ifx\ja\answer\RunningHeadtrue\else
\ifx\y\answer\RunningHeadtrue\else
\ifx\yes\answer\RunningHeadtrue\else
               \RunningHeadfalse\fi\fi\fi\fi
%    \end{macrocode}
% Since the file uses \Class{scrartcl} it assumes that
% \Package{scrpage} is available. We use \Package{scrpage} and not
% \Package{scrpage2}, because of maybe old \KOMAScript.
%    \begin{macrocode}
\ifRunningHead
\usepackage{scrpage}
\renewpagestyle{headings}{%
  (0pt,0pt)%
  {\strut\rightmark\ -- \leftmark\hfil}%
  {\hfil\strut\rightmark\ -- \leftmark}%
  {\hfil\strut\rightmark\ -- \leftmark\hfil}%
  (\textwidth,.4pt)%
  }{%
  (0pt,0pt)%
  {\pagemark\hfill}%
  {\hfill\pagemark}%
  {\hfill\pagemark\hfill}%
  (0pt,0pt)}
\fi
\def\headfont{\sffamily\bfseries}
%    \end{macrocode}
% Loading the Layout definition.
% If no filename is specified, adrdir will be used.
%    \begin{macrocode}
\ifx\adrformat\empty
  \def\adrformat{adrdir}
\fi
\InputIfFileExists{\adrformat.cfg}{}{%
  \typeout{^^J%
    *** File \adrformat.cfg not found!^^J%
    *** Datei \adrformat.cfg nicht gefunden!^^J%
    ^^J}
  }
%    \end{macrocode}
% All definitions are done, let's start with the document.
%    \begin{macrocode}
\begin{document}
%    \end{macrocode}
% Don't start a new page for every letter when running head is used.
%    \begin{macrocode}
\ifRunningHead
  \def\adrchar#1{\typeout{#1}}
\else
  \def\adrchar#1{\clearpage\typeout{#1}\markboth{#1}{#1}}
\fi
%    \end{macrocode}
% This command does all the formatting:
%    \begin{macrocode}
%\adrentry
% 1 {Nachname}
% 2 {Vorname}
% 3 {Strasse \\ PLZ Ort}
% 4 {Telefon\\Mobil}
% 5 {E-Mail} \ifEmail
% 6 {Organisation} 
% 7 {Notiz}
% 8 {Key}
\def\adrentry#1#2#3#4#5#6#7#8{\hspace{\adrindent}%
 \parbox[b]{\leftfield}
   {\raggedright \hspace{-\adrindent}{\sc #1}%
    \def\tempa{#1}\ifx \tempa\empty \else , #2\fi%
    \def\tempa{#3}\ifx \tempa\empty \else \par #3\fi%
    \ifEmail
      \def\tempa{#5}\ifx \tempa\empty \else \par \url{#5}\fi%
    \fi
    \def\tempa{#7}\ifx \tempa\empty \else \par (#7)\fi%
   }%
 \hfill%
 \parbox[b]{\rightfield}
   {\raggedleft%
    \def\tempa{#8}\ifx \tempa\empty \else {\scriptsize #8}\par \fi 
    {\small #4}%
   }\par%
 \ifRunningHead
   \markboth{#1}{#1}
 \fi
}
\ifx\adrfile\empty \else
     \InputIfFileExists{\adrfile.adr}{%
     \pagestyle{empty}
     \null\vfil
     \begin{center}
       {\Large \sfb \adrtitle\par}
     \end{center}
     \vfil\vfil\null
%    \end{macrocode}
% Always start on a right page
%    \begin{macrocode}
     \cleardoublepage
     \raggedbottom
     \pagestyle{headings}
     }{%
     \typeout{^^J%
              *** File \adrfile.adr not found!^^J%
              *** Datei \adrfile.adr nicht gefunden!^^J%
              ^^J}
     }
\fi
\end{document}
%    \end{macrocode}
% \iffalse
%</dir>
%</!cfg>
% \fi
%
%
% \section{The configuration files}
%
% \iffalse
%<*cfg>
% \fi
%    \begin{macrocode}
%<*dir>
%    \end{macrocode}
% Configfile for A6 phone book (105\,mm $\times$ 148\,mm).
% Original was former part of \KOMAScript{}.
%
%    \begin{macrocode}
\setlength{\paperwidth}{105mm}
\setlength{\textwidth}{85mm}
\setlength{\leftfield}{50mm}
\setlength{\rightfield}{30mm}
%    \end{macrocode}
%    \begin{macrocode}
\addtolength{\evensidemargin}{9mm}
\addtolength{\oddsidemargin}{\paperwidth}
\addtolength{\oddsidemargin}{-9mm}
\addtolength{\oddsidemargin}{-\textwidth}
%    \end{macrocode}
%    \begin{macrocode}
%</dir>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*planer>
%    \end{macrocode}
% Configfile for organizers (95\,mm $\times$ 172\,mm) maybe from
% ALDI.
%
%    \begin{macrocode}
\setlength{\paperwidth}{95mm}
\setlength{\textwidth}{70mm}
\setlength{\leftfield}{45mm}
\setlength{\rightfield}{25mm}
%    \end{macrocode}
%    \begin{macrocode}
\addtolength{\evensidemargin}{12mm}
\addtolength{\oddsidemargin}{12mm}
%    \end{macrocode}
%    \begin{macrocode}
%</planer>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*small>
%    \end{macrocode}
% Configfile for pocket calenders (87\,mm $\times$ 148\,mm)
% e.g. ``Sparkassenkalender''.
%
%    \begin{macrocode}
\setlength{\paperwidth}{87mm}
\setlength{\textwidth}{75mm}
\setlength{\leftfield}{45mm}
\setlength{\rightfield}{30mm}
%    \end{macrocode}
%    \begin{macrocode}
\addtolength{\evensidemargin}{9mm}
\addtolength{\oddsidemargin}{\paperwidth}
\addtolength{\oddsidemargin}{-9mm}
\addtolength{\oddsidemargin}{-\textwidth}
%    \end{macrocode}
%    \begin{macrocode}
%</small>
%    \end{macrocode}
%
%    \begin{macrocode}
\setlength{\adrindent}{1em}
\addtolength{\leftfield}{-\adrindent}
%    \end{macrocode}
%    \begin{macrocode}
%<*dir>
\setlength{\paperheight}{148mm}
\setlength{\textheight}{112mm}
%</dir>
%<*planer>
\setlength{\paperheight}{172mm}
\setlength{\textheight}{148mm}
%</planer>
%<*small>
\setlength{\paperheight}{148mm}
\setlength{\textheight}{112mm}
%</small>
\setlength{\headheight}{1.25\baselineskip}
\setlength{\headsep}{0.25\baselineskip}
\setlength{\footskip}{1.50\baselineskip}
\setlength{\topmargin}{-1in}
%<dir>\addtolength{\topmargin}{8mm}
%<planer|small>\addtolength{\topmargin}{7mm}
\setlength{\marginparwidth}{0in}
\setlength{\marginparsep}{0in}
\setlength{\marginparpush}{0in}
\setlength{\parskip}{0.5\baselineskip}
\setlength{\parindent}{0in}
\typeout{%
  ********************************************************************%
  ^^J^^J%
  DVIDVI Options:^^J%
  Front:^^J%
%<*dir|small>
%<dir>  1st Step (2 x A6 at A5)^^J%
%<small>  1st Step (2 x callenders at A5)^^J%
  -l xx -m 4:-1,2^^J%
  2nd Step (2 x A5 at A4)^^J%
  -m 2:0,1(0mm,148mm)^^J%
%</dir|small>
%<planer>  -l 24 -m 6:0(4mm,0mm),2(99mm,0mm),4(192mm,0mm)
  ^^J%
  Back:^^J%
%<*dir|small>
  1st Step^^J%
  -l xx -r -m 4:-3,0^^J%
  2nd Step^^J%
  -m 2:1,0(0mm,148mm)^^J%
%</dir|small>
%<planer>  -l 24 -r -m 6:5(8mm,0mm),3(103mm,0mm),1(198mm,0mm)
  ^^J%
%<dir|small>  xx must be the result of a multiplication with 4.^^J%
%<small>  Cut 36 mm from one side and tack in the middle.^^J%
  ^^J%
  ********************************************************************
  }
%    \end{macrocode}
% German Remark from Axel to \File{adrdir.cfg}:
% \begin{quote}
% Das ist die einfache Version, einfach in der Mitte durchschneiden,
% Seiten sortieren, ineinanderstecken und heften.
%
% Nicht alle Tacker k\"onnen dieses Format verarbeiten, ich habe
% lange gesucht und benutze den Novus B5, der passt ganz knapp und ist
% noch bezahlbar. Danach kommen die Hochleistungstacker \"uber 50 DM.
% \end{quote}
%
% German Remark from Axel to \File{adrplaner.cfg}:
% \begin{quote}
% Der Deskjet kann die letzten 14\,mm des Blattes nicht bedrucken,
% daher wurde das ganze Layout um 4\,mm verschoben, diese m\"ussen an
% der kurzen Kante abgeschnitten werden.
%
% Bei anderen Druckern kann man bei den Vorderseiten 3\,mm von der
% x-Koordinate abziehen und bei den R\"uckseiten zuaddieren.
% \end{quote}
%
% German Remark from Axel to \File{adrsmall.cfg}:
% \begin{quote}
% Von einer Seite m\"ussen noch 36\,mm abgeschnitten werden, dann
% in der Mitte heften und in den Taschenkalender einstecken.
% \end{quote}
%
% \iffalse
%</cfg>
% \fi
%
%
% \section{The \BibTeX{} files}
%
% \iffalse
%<*bst>
% \fi
%
% These \BibTeX{} files are BibTeX-Database to \Class{scrlettr}
% converters. They are based on BibTeX bibliography style
% \File{address} Gerd Neugebauer has written in 1994.
%
% The files generated from these files may be used for
% \Class{scrlettr}, \Class{scrlttr2}, \File{phone.tex} or
% \File{dir.tex} from the \KOMAScript{} Package, \Class{akletter} and
% some versions of \Class{myletter} which preceded
% \Class{akletter}. They will even work with the \LaTeX 2.09 version
% of \textsc{Script}.
%
% This is only one way to use the address database layout defined by
% Gerd Neugebauer. Use this as an example for your own conversion
% program.
%
% \changes{v1.0}{1996/01/01}{Added the key-field}
% \changes{v1.1}{1996/01/02}{Changed \texttt{net} to \texttt{url} and
%   \texttt{email}}
% \changes{v1.1.1}{1996/01/03}{Function address: moved
%   \texttt{\bslash\bslash} inside if condition}
% \changes{v1.1.1}{1996/01/03}{No more warnings if street is empty
%   (reported by Jan Holl\"ander)}
% \changes{v1.1.2}{1996/01/04}{The \emph{von} part was ignored in
%   names} 
% \changes{v1.1.3}{1996/01/04}{Support for second (mobile)
%   telephonenumber}
% \changes{v1.2}{1999/11/01}{New release independent of KOMA-Script}
% \changes{v1.2a}{2001/10/11}{\Package{docstrip} version}
% \changes{v1.2b}{2002/06/23}{Documentation updated}
% \changes{v1.2c}{2006/04/19}{Documentation updated, license information
% updated to LPPL 1.3}
% \changes{v1.3}{2010/04/02}{Removed \texttt{email.bst}, the email address is now
% written to the standard \texttt{bbl} by \texttt{adrconv}.}
% \changes{v1.3}{2010/04/02}{Renamed \texttt{birthday.bst}
% to \texttt{adrbirthday.bst} to avoid a collision with \texttt{directory.cls}.}
%
% The \File{adrbirthday.bst} prints the entries with birthdays only. The
% entries are sorted by month and inside one month by date.
%
%    \begin{macrocode}
ENTRY
  { name
  	sortas
    title
    organization
    city
    zip
    country
    street
    phone
    mobile
    fax
    url
    email
    note
    key
    birthday
    nbirthday
  }
  {}
%<!birthday>  { adr.char }
%<birthday>  { b.month }
%    \end{macrocode}
%    \begin{macrocode}
%<!birthday>INTEGERS { cur.adr.char }
%<birthday>STRINGS { cur.month num.index alpha.index }
%    \end{macrocode}
%    \begin{macrocode}
FUNCTION {get.names}
{ name empty$
   { organization empty$
      { "{}{}" }
      { organization "{}" * }
     if$
   }
   { "{" name #1 "{ll}" format.name$ "}" * *
     "{" name #1 "{ff}{ vv}" format.name$ "}" * * *
   }
   if$
}
%    \end{macrocode}
%    \begin{macrocode}
FUNCTION {print.adrchr}
%<*!birthday>
{ adr.char chr.to.int$ cur.adr.char >
  { newline$ "\adrchar{" adr.char "}" * * write$ newline$
    adr.char chr.to.int$ 'cur.adr.char :=
  }
  'skip$
%</!birthday>
%<*birthday>
{ b.month cur.month =
  'skip$
  { newline$ "\adrchar{\convdate{" b.month "}}" * * write$ newline$
    b.month 'cur.month :=
  }
%</birthday>
  if$
}
%    \end{macrocode}
%\iffalse
% $% <-- we do this to correct syntax highlight.
%\fi
%    \begin{macrocode}
%<*!fax>
FUNCTION{format.phone.and.mobile}
{ phone empty$
    {
      mobile empty$
        { "" }
        { mobile }
      if$
    }{
      mobile empty$
        { phone }
        { phone "\\" mobile * * }
      if$
    }
  if$
}
%</!fax>
%    \end{macrocode}
%    \begin{macrocode}
%<*fax>
FUNCTION{format.phone.and.fax}
{ phone empty$
    { "" }
    { phone }
  if$
  fax empty$
    'skip$
    { phone empty$
      { fax * }
      { "\\Fax:\\" fax * * }
      if$
    }
  if$
}
%</fax>
%    \end{macrocode}
%\iffalse
% $% <-- we do this to correct syntax hightlight.
%\fi
%    \begin{macrocode}
FUNCTION{address}
{
%<*birthday>
  nbirthday empty$
  'skip$
  {
%</birthday>
    print.adrchr
    "\adrentry" write$
    get.names write$ newline$
    "{" 
    street empty$
      { "" * }
      { street " \\ " * *}
    if$
    zip empty$
      { "" * }
      { zip " " * *}
    if$
    city empty$
    { "" * }
    { city * }
    if$ 
    "}{" *
%<!fax>    format.phone.and.mobile
%<fax>    format.phone.and.fax
    "}" * *
    email empty$
      { "{}" * }
      { "{" email "}" * * * }
    if$
     organization empty$
      { "{}" * }
      { "{" organization "}" * * *}
     if$
    note empty$
      { "{}" * }
      { "{" note "}" * * * }
    if$
    "{"  * 
%<*birthday>
    birthday empty$
      { "" }
      { birthday }
    if$
    "}{" * *
%</birthday>
    key empty$
      { "" }
      { key }
    if$
    "}" * * write$ newline$
%<*birthday>
  }
  if$
%</birthday>
}
%    \end{macrocode}
%    \begin{macrocode}
FUNCTION{presort}
%<*!birthday>
{
  sortas empty$
  { name empty$
    { organization empty$
      { key empty$
        { "No name, organization, or key to sort " cite$ * warning$
          "???"
        }
        { key }
        if$
      }
      { organization }
      if$
    }
    { name #1 "{ll},{f }{v }{, j}" format.name$ }
    if$
  }
  { sortas }
%</!birthday>
%<*birthday>
{ nbirthday empty$
  { "" }
  { nbirthday }
%</birthday>
  if$
  duplicate$
  'sort.key$ :=
%<*!birthday>
  #1 #1 substring$
  'adr.char :=
%</!birthday>
%<*birthday>
  #1 #2 substring$
  'b.month :=
%</birthday>
%    \end{macrocode}
% At every but \File{adrbirthday.bst} the adr.char is the first letter of
% the sort.key.
%    \begin{macrocode}
}
%    \end{macrocode}
%    \begin{macrocode}
READ
%    \end{macrocode}
%    \begin{macrocode}
ITERATE {presort}
%    \end{macrocode}
%    \begin{macrocode}
SORT
%    \end{macrocode}
%    \begin{macrocode}
FUNCTION {begin.bib}
{ 
%<*birthday>
  "\def\convdate#1{\ifcase#1 \or 1 \or 2 \or 3 \or 4 \or 5 "
  "\or 6 \or 7 \or 8 \or 9 \or 10 \or 11 \or 12 \fi}" * 'num.index :=
  "\def\convdate#1{\ifcase#1 \or Januar \or Februar \or "
  " M{^^b a}rz \or April \or Mai \or Juni \or Juli "
  "\or August \or September \or Oktober \or November \or Dezember \fi}"
  * * 'alpha.index :=
  alpha.index write$
  newline$
%</birthday>
  preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
%<!birthday>  #0 'cur.adr.char :=
%<birthday>  "00" 'cur.month :=
}
%\iffalse
% $% <-- we do this to correct syntax hightlight.
%\fi
%    \begin{macrocode}
EXECUTE {begin.bib}
%    \end{macrocode}
%    \begin{macrocode}
ITERATE {call.type$}
%    \end{macrocode}
% Print a newline and flush the write buffer
%    \begin{macrocode}
FUNCTION {end.bib}
{ newline$ }
%    \end{macrocode}
%    \begin{macrocode}
EXECUTE {end.bib}
%    \end{macrocode}
%
% \iffalse
%</bst>
% \fi
%
%
% \section{An example \BibTeX{} database}
%
% Do not believe everything you read here. It is just a
% demonstration.
% 
% \iffalse
%<*bib>
%<*example>
% \fi
%    \begin{macrocode}

@address{VornameNachname,
   name =         {Vorname Nachname},
   street =       {Strasse},
   zip =          {PLZ},
   city =         {Ort},
   phone =        {Telefon},
   email =        {E-mail@domain},
   mobile =       {Mobil},  
   birthday =     {Geburtstag},
   note =         {Notiz},
   organization = {Organisation},
   key =          {Key},
   nbirthday =    {0101},
}

@address{mustermann,
   name =    {Hans Mustermann},
   city =    {Heimstatt},
   zip =     01234,
   country = {D -},
   street =  {Einbahnstra{\ss}e 1},
   phone =   {01234 / 5 67 89},
   fax =     {01234 / 5 67 89},
   email =   {hm@work.com},
   note =    {Alles nur Erfindung},
}
@address{AxelK,
   name =      {Axel Kielhorn},
   city =      {Verden},
   zip =       27283,
   street =    {Lange Stra{\ss}e 17},
   phone =     {04231 / 12 34 56},
   fax =       {04231 / 65 34 21},
   email =     {a.kielhorn@web.de},
   key =       {Aki},
   note =      {Author of the modified addressen.bst},
   birthday =  {16.05.1967},
   nbirthday = 0516,         
}
@address{RalfK,
   name =      {Ralf Kielhorn},
   city =      {Braunschweig},
   zip =       38116,
   street =    {Gro{\ss}e Stra{\ss}e 17},
   phone =     {0531 / 12 34 56},
   key =       {Rki},
   birthday =  {05.08.1969},
   nbirthday = 0805,
}
@address{SabineK,
   name =      {Sabine Kielhorn},
   city =      {Oldenburg},
   zip =       26133,
   street =    {Fraunhoferstra{\ss}e 21},
   phone =     {0441 / 12 34 56},
   key =       {Ski},
   birthday =  {13.11.1970},
   nbirthday = 1113,
}
@address{OEKZ,
   name =        {{{"O}kologisches Zentrum~e.\,V.}},
   sortas =      {Okologisches Zentrum},
   organization = {Verband der Vereine},
   city =        {Heimstatt},
   zip =         01234,
   country =     {Germany},
   street =      {Mauerstra{\ss}e 1},
   phone =       {01234 / 5 67 89},
   fax =         {01234 / 5 67 89},
   email =       {hm@work.com},
   key =         {OEKZ},
}
@address{DANTE,
  name      = {{DANTE~e.\,V.}},
  sortas    = {Dante},
  street    = {Postfach 10 18 40},
  zip       = {69008},
  city      = {Heidelberg},
  phone     = {0 62 21 / 2 97 66},
  fax       = {0 62 21 / 16 79 06},
  email     = {dante@dante.de},
  url       = {http://www.dante.de},
  key       = {DANTE},
  birthday  = {14. April 1989},
  nbirthday = {0414}
  }

%    \end{macrocode}
%
% \iffalse
%</example>
%</bib>
% \fi
% \changes{v1.3}{2010/04/02}{Added support for PDF workflow.}
%<*montage>
%    \begin{macrocode}
\documentclass{article}
\usepackage{geometry}
\geometry{verbose,twoside,nofoot,pdftex,%
%<erster>a5paper, top=0mm,bottom=0mm,inner=0mm}
%<zweiter>a4paper,top=0mm,bottom=0mm,inner=0mm}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={-},
landscape,
nup=1x2,
%<erster>signature=16,
%<zweiter>signature=4,
%<erster>noautoscale,scale=1]{adrdir.pdf}
%<zweiter>noautoscale,scale=1]{adrmontage1.pdf}
\end{document}
%    \end{macrocode}
%</montage>
%
% \Finale
\endinput
%
% end of file ``adrconv.dtx''
