summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scraddr.dtx
blob: f01483bf594185edbd07c7638f2bc7506b648b28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
% \iffalse meta-comment
% ======================================================================
% scraddr.dtx
% Copyright (c) Markus Kohm, 2006-2022
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX 
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in manifest.txt.
% ======================================================================
%%% From File: $Id: scraddr.dtx 3688 2022-02-10 08:26:37Z kohm $
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\ProvidesFile{scraddr.dtx}
%</dtx>>
%<scraddr>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%<driver>\ProvidesFile{scraddr.drv}
%<scraddr>\ProvidesPackage{scraddr}
%<*dtx|scraddr|driver>
              [2022/01/24 v1.1d KOMA-Script
%</dtx|scraddr|driver>
%<scraddr>               package]
%<*dtx|driver>
              Script bundle]
%</dtx|driver>
%<*dtx>
\ifx\documentclass\undefined
  \input scrdocstrip.tex
  \@@input scrkernel-version.dtx
  \@@input scrstrip.inc
  \KOMAdefVariable{COPYRIGHTFROM}{2006}
  \generate{\usepreamble\defaultpreamble
    \file{scraddr.sty}{%
      \from{scraddr.dtx}{scraddr}%
      \from{scrlogo.dtx}{logo}%
    }%
  }
  \@@input scrstrop.inc
\else
  \let\endbatchfile\relax
\fi
\endbatchfile
%</dtx>
%<*driver>
\documentclass{koma-script-source-doc}
\usepackage[USenglish]{babel}
\begin{document}
  \DocInput{scraddr.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{v1.1a}{2002/05/19}{first version, separated from \cls{scrlettr}}
% \changes{v1.1d}{2022/01/24}{switched from \cls{scrdoc} to
%   \cls{koma-script-source-doc}}
% \changes{v1.1d}{2022/01/24}{whole implementation documentation in English}
%
% \GetFileInfo{scraddr.dtx}
% \title{Parsing Address Files \\
%   Using Package \pkg*{scraddr}}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}
%   \and Jens-Uwe Morawski}
% \date{Version \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
% Address files are not only of interest for letters using the \KOMAScript{}
% class \cls*{scrlttr2} or the \KOMAScript{} package \pkg*{scrletter}. Other
% applications such as the creation of address books or telephone directories
% are also quite common. In addition, it can also be useful to access not only
% the addressee's record in a letter, but also other records in an address
% file. This is exactly the task of the \pkg*{scraddr} package.
% \end{abstract}
% \tableofcontents
%
% \section{User Manual}
%
% You can find the user manual of \pkg*{scraddr} in the \KOMAScript{} manual,
% either the German \file{scrguide} or the English \file{scrguien}.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation}
%
%\iffalse
%    \begin{macrocode}
%<*scraddr>
%<*beta>
\PackageWarningNoLine{scraddr}
  {THIS IS A BETA VERSION!\MessageBreak
    YOU SHOULD NOT USE THIS VERSION!\MessageBreak
    YOU SHOULD INSTALL THE RELEASE FROM CTAN\MessageBreak
    AND USE THAT INSTEAD OF THIS BETA VERSION}
%</beta>
%</scraddr>
%\fi
%
% \changes{v1.0}{1996/01/22}{New package \pkg*{scraddr}}
%
%    \begin{macrocode}
%<*scraddr>
%    \end{macrocode}
%
% \subsection{Options}
%
% Preliminary note: \pkg*{scraddr} is a very, very old package from the early
% days of \KOMAScript. Therefore it does not support \emph{key=value} options
% as other \KOMAScript{} packages do.
%
% \begin{option}{adrFreeIVempty}
% \changes{v1.1a}{2002/05/19}{new}
% \begin{option}{adrFreeIVshow}
% \changes{v1.1a}{2002/05/19}{new}
% \begin{option}{adrFreeIVwarn}
% \changes{v1.1a}{2002/05/19}{new}
% \begin{option}{adrFreeIVstop}
% \changes{v1.1a}{2002/05/19}{new}
% \begin{macro}{\@adrFIVerror}
% \changes{v1.1a}{2002/05/19}{new}
% The options allow the choice whether \cs{FreeIV}, defined by \cs{adrentry},
% should be ignored, output, result in a warning or an error message. Default
% is \opt{adrFreeIVshow}. The selected choice is stored as a number in
% \cs{@adrFIVerror} (0 = \opt{adrFreeIVempty}, 1 = \opt{adrFreeIVshow},
% 2 = \opt{adrFreewarn}, 3 = \opt{adrFreeIVstop}). Unknown values should
% be handled as \opt{adrFreeIVstop} too, but are not recommended.
%    \begin{macrocode}
\newcommand*{\@adrFIVerror}{}
\DeclareOption{adrFreeIVempty}{\renewcommand*{\@adrFIVerror}{0}}
\DeclareOption{adrFreeIVshow}{\renewcommand*{\@adrFIVerror}{1}}
\DeclareOption{adrFreeIVwarn}{\renewcommand*{\@adrFIVerror}{2}}
\DeclareOption{adrFreeIVstop}{\renewcommand*{\@adrFIVerror}{3}}
%    \end{macrocode}
%  \end{macro}
%  \end{option}
%  \end{option}
%  \end{option}
%  \end{option}
%
% \changes{v1.0a}{2001/08/07}{\cs{ExecuteOption}\cs{relax} fixed}
% \changes{v1.1a}{2002/05/19}{\texttt{adrFreeIVshow} is default}
%    \begin{macrocode}
\ExecuteOptions{adrFreeIVshow}
\ProcessOptions\relax
%    \end{macrocode}
%
% \subsection{Reading address files}
% \begin{command}{\InputAdressFile}
% This command reads the address file given as mandatory argument. While
% reading global internal macros are generated for every \cs{adrentry} or
% \cs{addrentry}. To do so, these two macros are redefined locally only.
% \changes{v1.1}{2002/05/18}{extended by \cs{addrentry} handling}
% \changes{v1.1b}{2002/06/02}{\cs{addrchar} and \cs{adrchar} are defined also
%   if undefined}
%    \begin{macrocode}
\newcommand{\InputAddressFile}[1]{\begingroup
  \ifcase\@adrFIVerror
    \def\adrentry##1##2##3##4##5##6##7{%
      \addrentry{##1}{##2}{##3}{##4}{##5}{##6}{##7}{}}%
  \or
    \def\adrentry##1##2##3##4##5##6##7##8{%
      \addrentry{##1}{##2}{##3}{##4}{##5}{##6}{##7}{%
        (entry FreeIV undefined at `##8')}{##8}}%
  \or
    \def\adrentry##1##2##3##4##5##6##7##8{%
      \addrentry{##1}{##2}{##3}{##4}{##5}{##6}{##7}{%
        \PackageWarning{scraddr}{%
          `##8' was defined using \string\adrentry\MessageBreak
          so \string\FreeIV-entry is not defined}}{##8}}%
  \else
    \def\adrentry##1##2##3##4##5##6##7##8{%
      \addrentry{##1}{##2}{##3}{##4}{##5}{##6}{##7}{%
        \PackageError{scraddr}{%
          \string\FreeIV\space undefined at `##8'}{%
          `##8' was defined using \string\adrentry\MessageBreak
           so \string\FreeIV-entry is not defined.\MessageBreak
          You may continue but you should check output}}{##8}}%
  \fi
  \providecommand*{\addrchar}[1]{}%
  \providecommand*{\adrchar}{\addrchar}%
  \def\addrentry##1##2##3##4##5##6##7##8##9{%
    \def\@tempa{##9}\ifx\@tempa\@empty\else
      \expandafter\gdef\csname ##9.LN\endcsname{##1}
      \expandafter\gdef\csname ##9.FN\endcsname{##2}
      \expandafter\gdef\csname ##9.A\endcsname{##3}
      \expandafter\gdef\csname ##9.P\endcsname{##4}
      \expandafter\gdef\csname ##9.FI\endcsname{##5}
      \expandafter\gdef\csname ##9.FII\endcsname{##6}
      \expandafter\gdef\csname ##9.FIII\endcsname{##7}
      \expandafter\gdef\csname ##9.FIV\endcsname{##8}    
    \fi}
%    \end{macrocode}
% Not existing files result in an error message. Found files are only noted.
%    \begin{macrocode}
  \InputIfFileExists{#1.adr}
                    {\typeout{Load addressfile: #1.adr.}}
                    {\PackageError{scraddr}
                                  {File #1.adr not found}
                                  {The addressfile you wanted is not
                                   available}}
  \endgroup}
%    \end{macrocode}
%  \end{command}
%
% \subsection{Using an element of an address file}
%
% Selecting the elements by names instead of cryptic macros, could be
% easier. So we use well named macros for the selection. All these macros have
% exactly one mandatory argument: the \meta{shortcut} which is argument 8 of
% \cs{adrentry} resp. argument 9 of \cs{addrentry} in the address file.
%
% \begin{command}{\Name}
% The \cs{Name} is a combination of \cs{Firstname} and \cs{Lastname} with a
% normal word separator space in between.
%    \begin{macrocode}
\newcommand*{\Name}[1]{\FirstName{#1}\ \LastName{#1}}
%    \end{macrocode}
% \end{command}
% \begin{command}{\FirstName}
% Firstname or given from internal macro \cs{\meta{shortcut}.FN}.
%    \begin{macrocode}
\newcommand*{\FirstName}[1]{\csname #1.FN\endcsname}
%    \end{macrocode}
% \end{command}
% \begin{command}{\LastName}
% Lastname from internal macro \cs{\meta{shortcut}.LN}.
%    \begin{macrocode}
\newcommand*{\LastName}[1]{\csname #1.LN\endcsname}
%    \end{macrocode}
% \end{command}
% \begin{command}{\Address}
% Address from internal macro \cs{\meta{shortcut}.A}.
%    \begin{macrocode}
\newcommand*{\Address}[1]{\csname #1.A\endcsname}
%    \end{macrocode}
% \end{command}
% \begin{command}{\Telephone}
% Telephone number from internal macro \cs{\meta{shortcut}.P}.
%    \begin{macrocode}
\newcommand*{\Telephone}[1]{\csname #1.P\endcsname}
%    \end{macrocode}
% \end{command}
% \begin{command}{\FreeI,\FreeII}
% Two free entries from internal macros \cs{\meta{shortcut}.FI} and
% \cs{\meta{shortcut}.FII}.
%    \begin{macrocode}
\newcommand*{\FreeI}[1]{\csname #1.FI\endcsname}
\newcommand*{\FreeII}[1]{\csname #1.FII\endcsname}
%    \end{macrocode}
% \end{command}
% \begin{command}{\Comment,\FreeIII}
% The third free element is available by two commands, because originally it
% was specified as \meta{comment}. It is stored in the internal macro
% \cs{\meta{shortcut}.FIII}.
% \changes{v1.1}{2002/05/18}{extended to \cs{addrentry}}
%    \begin{macrocode}
\newcommand*{\Comment}{}
\newcommand*{\FreeIII}[1]{\csname #1.FIII\endcsname}
\let\Comment\FreeIII
%    \end{macrocode}
% \end{command}
% \begin{command}{\FreeIV}
% Forth free entry from internal macro \cs{\meta{shortcut}.FIV} only available
% with \cs{addrentry} but not woth \cs{adreentry}.
% \changes{v1.1}{2002/05/18}{extended to \cs{addrentry}}
%    \begin{macrocode}
\newcommand*{\FreeIV}[1]{\csname #1.FIV\endcsname}
%    \end{macrocode}
% \end{command}
%
% \subsection{Ende of package}
%    \begin{macrocode}
%</scraddr>
%    \end{macrocode}
%
% \Finale
% \PrintChanges
%
\endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% TeX-engine: luatex-dev
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx"))
% End: