From 5b1c9fe4a8686f1d474467ad220e0714515d2a73 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 3 Feb 2014 23:45:48 +0000 Subject: datatool (3feb14) git-svn-id: svn://tug.org/texlive/trunk@32860 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/datatool/CHANGES | 12 ++ Master/texmf-dist/doc/latex/datatool/README | 8 +- .../doc/latex/datatool/datatool-code.pdf | Bin 908802 -> 913625 bytes .../doc/latex/datatool/datatool-user.pdf | Bin 600057 -> 601441 bytes .../doc/latex/datatool/datatool-user.tex | 43 ++++- .../doc/latex/datatool/samples/sample-barchart.pdf | Bin 35074 -> 35074 bytes .../latex/datatool/samples/sample-datatooltk.pdf | Bin 22860 -> 22860 bytes .../doc/latex/datatool/samples/sample-dict.pdf | Bin 122594 -> 122594 bytes .../doc/latex/datatool/samples/sample-gidx.pdf | Bin 180116 -> 180122 bytes .../doc/latex/datatool/samples/sample-glossary.pdf | Bin 104736 -> 104729 bytes .../doc/latex/datatool/samples/sample-index.pdf | Bin 128783 -> 128783 bytes .../latex/datatool/samples/sample-mail-merge.pdf | Bin 21642 -> 21885 bytes .../doc/latex/datatool/samples/sample-piechart.pdf | Bin 33964 -> 33964 bytes .../doc/latex/datatool/samples/sample-sort.pdf | Bin 61053 -> 61053 bytes .../datatool/samples/sample-student-scores.pdf | Bin 34615 -> 34615 bytes .../latex/datatool/samples/sample-two-per-row.pdf | Bin 31752 -> 31752 bytes .../texmf-dist/source/latex/datatool/datatool.dtx | 177 ++++++++++++++++++--- .../texmf-dist/source/latex/datatool/datatool.ins | 2 +- Master/texmf-dist/tex/latex/datatool/datatool.sty | 101 +++++++++--- 19 files changed, 285 insertions(+), 58 deletions(-) diff --git a/Master/texmf-dist/doc/latex/datatool/CHANGES b/Master/texmf-dist/doc/latex/datatool/CHANGES index 175bfb35174..ef25ed86ad0 100644 --- a/Master/texmf-dist/doc/latex/datatool/CHANGES +++ b/Master/texmf-dist/doc/latex/datatool/CHANGES @@ -1,3 +1,15 @@ +v2.20: + + * datatool: + + - added \DTLloaddbtex + + - added \DTLifnullorempty + + - added \DTLassignfirstmatch and \xDTLassignfirstmatch + + - Fixed bug in \DTLforeach* (\@dtl@dbname undefined) + v2.19: * datatool: diff --git a/Master/texmf-dist/doc/latex/datatool/README b/Master/texmf-dist/doc/latex/datatool/README index 9f93eadae57..283cdcb7a0f 100644 --- a/Master/texmf-dist/doc/latex/datatool/README +++ b/Master/texmf-dist/doc/latex/datatool/README @@ -1,9 +1,11 @@ -LaTeX Bundle : datatool v2.19 +LaTeX Bundle : datatool v2.20 -Last Modified : 2014-01-17 +Last Modified : 2014-02-03 Author : Nicola Talbot +Package FAQ : http://www.dickimaw-books.com/faqs/datatoolfaq.html + This bundle consists of the packages: datatool.sty, datatool-base.sty, datatool-fp.sty, datatool-pgfmath.sty, databar.sty, databib.sty, datapie.sty dataplot.sty, datagidx.sty @@ -128,7 +130,7 @@ The package and documentation source code is also supplied as a dtx and ins file located in texmf/source. This material is subject to the LaTeX Project Public License. -See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license. +See http://www.ctan.org/license/lppl1.3 for the details of that license. http://www.dickimaw-books.com/ diff --git a/Master/texmf-dist/doc/latex/datatool/datatool-code.pdf b/Master/texmf-dist/doc/latex/datatool/datatool-code.pdf index a0192a52006..9d28367745b 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/datatool-code.pdf and b/Master/texmf-dist/doc/latex/datatool/datatool-code.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/datatool-user.pdf b/Master/texmf-dist/doc/latex/datatool/datatool-user.pdf index a1941a87ab8..9833f3266f6 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/datatool-user.pdf and b/Master/texmf-dist/doc/latex/datatool/datatool-user.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/datatool-user.tex b/Master/texmf-dist/doc/latex/datatool/datatool-user.tex index 372ca7d0299..db2f306c297 100644 --- a/Master/texmf-dist/doc/latex/datatool/datatool-user.tex +++ b/Master/texmf-dist/doc/latex/datatool/datatool-user.tex @@ -91,11 +91,11 @@ \MakeShortVerb{"} \DeleteShortVerb{\|} - \title{User Manual for datatool bundle version~2.19} + \title{User Manual for datatool bundle version~2.20} \author{Nicola L.C. Talbot\\ \url{http://www.dickimaw-books.com/}} - \date{2014-01-17} + \date{2014-02-03} \maketitle \pagenumbering{roman} @@ -110,7 +110,7 @@ The \styfmt{datatool} bundle comes with the following documentation: \item[\url{datatool-code.pdf}] Advanced users wishing to know more about the inner workings of all the packages provided in the \styfmt{datatool} bundle should - read \qt{Documented Code for datatool v2.19} + read \qt{Documented Code for datatool v2.20} \item[INSTALL] Installation instructions. @@ -2227,7 +2227,7 @@ parse files that have newline characters within entries. The \app{datatooltk} application (see page~\pageref{datatooltk}) can parse them, so if you have multilined entries in a CSV file, you can convert it to \sty{datatool}'s internal database format using -\app{datatooltk} and the input it using \ics{input}. See the +\app{datatooltk} and the input it using \ics{input} or \ics{DTLloaddbtex}. See the \app{datatooltk} documentation for further details. \end{important} @@ -2498,7 +2498,7 @@ of key=value pairs. The following keys are available: \item[contcaption] The continuation caption. -\item[shortcaption] The caption to be used in the list of figures. +\item[shortcaption] The caption to be used in the list of tables. \item[label] The label for this table. @@ -3801,11 +3801,19 @@ This is the null value for a number. \begin{definition}[\DescribeMacro{\DTLifnull}]% \cs{DTLifnull}\marg{cmd}\marg{true part}\marg{false part} \end{definition} -This checks if \meta{cmd} is null where \meta{cmd} is a command name, +This checks if \meta{cmd} is null where \meta{cmd} is a control +sequence, if it is, then \meta{true part} is done, otherwise \meta{false part} is done. This macro is illustrated in \autoref{ex:null} below. +\begin{definition}[\DescribeMacro{\DTLifnullorempty}] +\cs{DTLifnullorempty}\marg{cmd}\marg{true part}\marg{false part} +\end{definition} +This checks if \meta{cmd} is null or empty, where \meta{cmd} is a +control sequence. If it is it does \meta{true part}, otherwise +\meta{false part}. + \begin{example}{Null Values}{ex:null} Consider the following (which creates a database called "emailDB"): \begin{verbatim} @@ -4863,7 +4871,14 @@ any use: \begin{definition}[\DescribeMacro{\DTLprotectedsaverawdb}]% \cs{DTLprotectedsaverawdb}\marg{db name}\marg{filename} \end{definition} -instead. +instead. The \app{datatooltk} application +can read and write this raw format. To load a file in this format +you can just use \cs{input} or you can use: +\begin{definition} +\cs{DTLloaddbtex}\marg{cs}\marg{file} +\end{definition} +This checks for the file's existence and assigns the database name to the +control sequence \meta{cs}. \begin{important} If you find a~problem caused by \TeX's automatic insertion of a line @@ -5068,6 +5083,20 @@ This (globally) assigns the list of commands in \meta{assign list} for row \meta{row idx} in database \meta{db name}, where \meta{assign list} has the same format as in \ics{DTLforeach}. +\begin{definition} +\cs{DTLassignfirstmatch}\marg{db name}\marg{col key}\marg{value}\marg{assign list} +\end{definition} +This is similar to \cs{DTLassign} except that it applies to the +first row in the given database where the column identified by the +label \meta{col key} has the given value. Note that no expansion is +performed in the match. The value must be an exact match. + +\begin{definition} +\cs{xDTLassignfirstmatch}\marg{db name}\marg{col key}\marg{value}\marg{assign list} +\end{definition} +This is like \cs{DTLassignfirstmatch} but performs a~\emph{one-level} +expansion on \meta{value}. + Two rows can be swapped using: \begin{definition}[\DescribeMacro{\DTLswaprows}]% \cs{DTLswaprows}\marg{db name}\marg{row1 index}\marg{row2 index} diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-barchart.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-barchart.pdf index 17044288c1b..b150c9f9fef 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-barchart.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-barchart.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-datatooltk.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-datatooltk.pdf index 393b0bd3cf5..0758d182ba8 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-datatooltk.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-datatooltk.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-dict.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-dict.pdf index 684937017cf..160f341c484 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-dict.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-dict.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-gidx.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-gidx.pdf index d2d1b4fe58a..74bef9cc213 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-gidx.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-gidx.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-glossary.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-glossary.pdf index 701f67fc3c8..1efa20caaa6 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-glossary.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-glossary.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-index.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-index.pdf index a9bbadda262..1fd01ce35b8 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-index.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-index.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-mail-merge.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-mail-merge.pdf index d37597a1005..18c7c59c940 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-mail-merge.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-mail-merge.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-piechart.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-piechart.pdf index 59a472f70e2..92223a3d67d 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-piechart.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-piechart.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-sort.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-sort.pdf index 4d8764d920e..06ddbdc1fe2 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-sort.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-sort.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-student-scores.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-student-scores.pdf index 80681527934..0ac59407a3e 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-student-scores.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-student-scores.pdf differ diff --git a/Master/texmf-dist/doc/latex/datatool/samples/sample-two-per-row.pdf b/Master/texmf-dist/doc/latex/datatool/samples/sample-two-per-row.pdf index 5a91c1b86b7..0832275c680 100644 Binary files a/Master/texmf-dist/doc/latex/datatool/samples/sample-two-per-row.pdf and b/Master/texmf-dist/doc/latex/datatool/samples/sample-two-per-row.pdf differ diff --git a/Master/texmf-dist/source/latex/datatool/datatool.dtx b/Master/texmf-dist/source/latex/datatool/datatool.dtx index ac9fe123f73..9e9ddec7ae3 100644 --- a/Master/texmf-dist/source/latex/datatool/datatool.dtx +++ b/Master/texmf-dist/source/latex/datatool/datatool.dtx @@ -19,7 +19,7 @@ % -author "Nicola Talbot" % -codetitle "" % datatool -% Created on 2014/1/17 12:07 +% Created on 2014/2/3 15:28 %\fi %\iffalse %<*package> @@ -66,7 +66,7 @@ datatool.dtx \doxitem{Counter}{counter}{counters} \doxitem{Option}{option}{package options} -\CheckSum{22929} +\CheckSum{22983} \RecordChanges \PageIndex @@ -79,11 +79,11 @@ datatool.dtx %\fi %\MakeShortVerb{"} % -%\title{Documented Code for datatool v2.19} +%\title{Documented Code for datatool v2.20} %\author{Nicola L. C. Talbot\\ %\url{http://www.dickimaw-books.com/}} % -%\date{2014-01-17} +%\date{2014-02-03} %\maketitle % %\pagenumbering{roman} @@ -5708,7 +5708,7 @@ datatool.dtx %\section{Package Declaration} % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{datatool}[2014/01/17 v2.19 (NLCT)] +\ProvidesPackage{datatool}[2014/02/03 v2.20 (NLCT)] % \end{macrocode} % Load required packages: % \begin{macrocode} @@ -7160,13 +7160,79 @@ datatool.dtx %\changes{2.10}{2012-07-18}{new} % \begin{macrocode} \newcommand*{\DTLassign}[3]{% + \DTLifdbexists{#1} + {% % \end{macrocode} % Grouped in the event that \cs{dtlcurrentrow} is already in use. % (Assignments in \cs{@dtl@assign} are global.) % \begin{macrocode} - {% - \dtlgetrow{#1}{#2}% + {% + \dtlgetrow{#1}{#2}% \@dtl@assign{#3}{#1}% + }% + }% + {% + \PackageError{datatool}{Database `#1' doesn't exist}{}% + }% +} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\DTLassignfirstmatch} +%\begin{definition} +%\cs{DTLassignfirstmatch}\marg{db}\marg{col key}\marg{value}\marg{assign list} +%\end{definition} +% Applies the assignment list to the first row that has the given +% value in the given column. (Value must be expanded.) +%\changes{2.20}{2014-02-14}{new} +% \begin{macrocode} +\newcommand*{\DTLassignfirstmatch}[4]{% + \dtl@assignfirstmatch{#3}{#1}{#2}{#4}% +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\xDTLassignfirstmatch} +%\begin{definition} +%\cs{xDTLassignfirstmatch}\marg{db}\marg{col key}\marg{value}\marg{assign list} +%\end{definition} +% Applies the assignment list to the first row that has the given +% value in the given column. (Performs \emph{one level} expansion on +% \meta{value}.) +%\changes{2.20}{2014-02-14}{new} +% \begin{macrocode} +\newcommand*{\xDTLassignfirstmatch}[4]{% + \protected@edef\@dtl@asg@value{\expandonce{#3}}% + \expandafter\dtl@assignfirstmatch\expandafter + {\@dtl@asg@value}{#1}{#2}{#4}% +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\dtl@assignfirstmatch} +% Internal swaps the ordering around so the value is first. (This +% just makes it easier for \cs{xDTLassignfirstmatch} +% \begin{macrocode} +\newcommand*{\dtl@assignfirstmatch}[4]{% + \DTLifdbexists{#2}% + {% +% Grouped in the event that \cs{dtlcurrentrow} is already in use. +% (Assignments in \cs{@dtl@assign} are global.) +% \begin{macrocode} + {% +% \end{macrocode} +% Get row idx: +% \begin{macrocode} + \dtlgetrowindex{\dtl@asg@rowidx}{#2}{\dtlcolumnindex{#2}{#3}}{#1}% + \ifx\dtl@asg@rowidx\dtlnovalue + \PackageError{datatool}{No match found for + \string\DTLassignfirstmatch{#2}{#3}{#1}{#4}}{}% + \else + \dtlgetrow{#2}{\dtl@asg@rowidx}% + \@dtl@assign{#4}{#2}% + \fi + }% + }% + {% + \PackageError{datatool}{Data base `#2' doesn't exist}{}% }% } % \end{macrocode} @@ -7180,9 +7246,13 @@ datatool.dtx % The current row must be stored in \cs{dtlcurrentrow}. %\changes{2.0}{2009 February 27}{updated to use new database % structure} +%\changes{2.20}{2014-02-14}{Added check for empty argument}% % \begin{macrocode} \newcommand*{\@dtl@assign}[2]{% - \@dtl@assigncmd#1,\@nil\@@{#2}% + \ifstrempty{#1}{}% + {% + \@dtl@assigncmd#1,\@nil\@@{#2}% + }% } % \end{macrocode} %\end{macro} @@ -7196,6 +7266,12 @@ datatool.dtx % \begin{macrocode} \def\@dtl@assigncmd#1#2=#3,#4\@@#5{% % \end{macrocode} +% Store database label. (This may already have been done so \cs{edef} +% is used to prevent infinite recursion.) +%\changes{2.20}{2014-02-03}{Stored db label in \cs{@dtl@dbname}} +% \begin{macrocode} + \edef\@dtl@dbname{#5}% +% \end{macrocode} % get entry for ID given by \#3 and store in \#2 % \begin{macrocode} \@sDTLifhaskey{#5}{#3}% @@ -7207,9 +7283,11 @@ datatool.dtx % \end{macrocode} % Set to null if required % \begin{macrocode} - \ifx#1\dtlnovalue + \ifdefequal{#1}{\dtlnovalue}% + {% \@@dtl@setnull{#1}{#3}% - \fi + }% + {}% % \end{macrocode} % Make it global % \begin{macrocode} @@ -7351,6 +7429,18 @@ datatool.dtx % \end{macrocode} %\end{macro} % +%\begin{macro}{\DTLifnullorempty} +%\begin{definition} +%\cs{DTLifnullorempty}\marg{command}\marg{true part}\marg{false part} +%\end{definition} +%\changes{2.20}{2014-02-14}{new} +% \begin{macrocode} +\newcommand*{\DTLifnullorempty}[3]{% + \ifdefempty{#1}{#2}{\DTLifnull{#1}{#2}{#3}}% +} +% \end{macrocode} +%\end{macro} +% %\begin{macro}{\@dtlnovalue} % \begin{macrocode} \def\@dtlnovalue{Undefined Value} @@ -8618,8 +8708,9 @@ datatool.dtx \global\c@DTLrow=\c@DTLrow\relax % \end{macrocode} % Store database name +%\changes{2.20}{2014-02-03}{change \cs{gdef} to \cs{xdef}} % \begin{macrocode} - \gdef\@dtl@dbname{#2}% + \xdef\@dtl@dbname{#2}% % \end{macrocode} % Increment level and check not exceeded 3 % \begin{macrocode} @@ -8891,6 +8982,11 @@ datatool.dtx % \begin{macrocode} \global\c@DTLrow=\c@DTLrow % \end{macrocode} +% Store database name. +%\changes{2.20}{2014-02-03}{Added missing \cs{@dtl@dbname} assignment} +% \begin{macrocode} + \xdef\@dtl@dbname{#2}% +% \end{macrocode} % Increment level and check not exceeded 3 % \begin{macrocode} \global\advance\dtlforeachlevel by 1\relax @@ -10482,18 +10578,18 @@ datatool.dtx % \end{macrocode} % Iterate over all the listed data bases % \begin{macrocode} - \@for\@dtl@dbname:=#2\do{% + \@for\@dtl@db@name:=#2\do{% % \end{macrocode} % Iterate through this database (using read only version) % \begin{macrocode} - \@sDTLforeach{\@dtl@dbname}% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% % \end{macrocode} % Iterate through key list. % \begin{macrocode} \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -10585,18 +10681,18 @@ datatool.dtx % \end{macrocode} % Iterate over all the listed data bases % \begin{macrocode} - \@for\@dtl@dbname:=#2\do{% + \@for\@dtl@db@name:=#2\do{% % \end{macrocode} % Iterate through this database (using read only version) % \begin{macrocode} - \@sDTLforeach{\@dtl@dbname}% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% % \end{macrocode} % Iterate through key list. % \begin{macrocode} \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -10705,18 +10801,18 @@ datatool.dtx % \end{macrocode} % Iterate over all the listed data bases % \begin{macrocode} - \@for\@dtl@dbname:=#2\do{% + \@for\@dtl@db@name:=#2\do{% % \end{macrocode} % Iterate through this database (using read only version) % \begin{macrocode} - \@sDTLforeach{\@dtl@dbname}% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% % \end{macrocode} % Iterate through key list. % \begin{macrocode} \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -10881,18 +10977,18 @@ datatool.dtx % \end{macrocode} % Iterate over all the listed data bases % \begin{macrocode} - \@for\@dtl@dbname:=#2\do{% + \@for\@dtl@db@name:=#2\do{% % \end{macrocode} % Iterate through this database (using read only version) % \begin{macrocode} - \@sDTLforeach{\@dtl@dbname}% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% % \end{macrocode} % Iterate through key list. % \begin{macrocode} \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -10997,18 +11093,18 @@ datatool.dtx % \end{macrocode} % Iterate over all the listed data bases % \begin{macrocode} - \@for\@dtl@dbname:=#2\do{% + \@for\@dtl@db@name:=#2\do{% % \end{macrocode} % Iterate through this database (using read only version) % \begin{macrocode} - \@sDTLforeach{\@dtl@dbname}% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% % \end{macrocode} % Iterate through key list. % \begin{macrocode} \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -12381,6 +12477,35 @@ datatool.dtx % %\section{Loading a database from an external file} % +%\begin{macro}{\DTLloaddbtex} +%\begin{definition} +%\cs{DTLloaddbtex}\marg{cs}\marg{file} +%\end{definition} +% Load a \texttt{.dbtex} file and assign the database name to the +% control sequence \meta{cs}. Checks the file name exists and the +% control sequence doesn't exist. +%\changes{2.20}{2014-02-14}{new} +% \begin{macrocode} +\newcommand*{\DTLloaddbtex}[2]{% + \IfFileExists{#2}% + {% + \input{#2}% + \ifdef#1% + {% + \PackageError{datatool}{Command \string#1\space is already defined}% + {}% + }% + {% + \let#1\dtllastloadeddb + }% + }% + {% + \PackageError{datatool}{File `#2' doesn't exist.}{}% + }% +} +% \end{macrocode} +%\end{macro} +% %\begin{macro}{\@dtl@read} % \begin{macrocode} \newread\@dtl@read diff --git a/Master/texmf-dist/source/latex/datatool/datatool.ins b/Master/texmf-dist/source/latex/datatool/datatool.ins index be1294e0d3f..a4eb3b78d52 100644 --- a/Master/texmf-dist/source/latex/datatool/datatool.ins +++ b/Master/texmf-dist/source/latex/datatool/datatool.ins @@ -1,4 +1,4 @@ -% datatool.ins generated using makedtx version 1.1 2014/1/17 12:07 +% datatool.ins generated using makedtx version 1.1 2014/2/3 15:28 \input docstrip \preamble diff --git a/Master/texmf-dist/tex/latex/datatool/datatool.sty b/Master/texmf-dist/tex/latex/datatool/datatool.sty index 7d85323adc7..af902a2cf02 100644 --- a/Master/texmf-dist/tex/latex/datatool/datatool.sty +++ b/Master/texmf-dist/tex/latex/datatool/datatool.sty @@ -39,7 +39,7 @@ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{datatool}[2014/01/17 v2.19 (NLCT)] +\ProvidesPackage{datatool}[2014/02/03 v2.20 (NLCT)] \RequirePackage{xkeyval} \RequirePackage{ifthen} \RequirePackage{xfor} @@ -614,24 +614,62 @@ \newcommand{\DTLifdbexists}[3]{% \@ifundefined{dtldb@#1}{#3}{#2}} \newcommand*{\DTLassign}[3]{% + \DTLifdbexists{#1} {% - \dtlgetrow{#1}{#2}% + {% + \dtlgetrow{#1}{#2}% \@dtl@assign{#3}{#1}% + }% + }% + {% + \PackageError{datatool}{Database `#1' doesn't exist}{}% + }% +} +\newcommand*{\DTLassignfirstmatch}[4]{% + \dtl@assignfirstmatch{#3}{#1}{#2}{#4}% +} +\newcommand*{\xDTLassignfirstmatch}[4]{% + \protected@edef\@dtl@asg@value{\expandonce{#3}}% + \expandafter\dtl@assignfirstmatch\expandafter + {\@dtl@asg@value}{#1}{#2}{#4}% +} +\newcommand*{\dtl@assignfirstmatch}[4]{% + \DTLifdbexists{#2}% + {% + {% + \dtlgetrowindex{\dtl@asg@rowidx}{#2}{\dtlcolumnindex{#2}{#3}}{#1}% + \ifx\dtl@asg@rowidx\dtlnovalue + \PackageError{datatool}{No match found for + \string\DTLassignfirstmatch{#2}{#3}{#1}{#4}}{}% + \else + \dtlgetrow{#2}{\dtl@asg@rowidx}% + \@dtl@assign{#4}{#2}% + \fi + }% + }% + {% + \PackageError{datatool}{Data base `#2' doesn't exist}{}% }% } \newcommand*{\@dtl@assign}[2]{% - \@dtl@assigncmd#1,\@nil\@@{#2}% + \ifstrempty{#1}{}% + {% + \@dtl@assigncmd#1,\@nil\@@{#2}% + }% } \def\@dtl@assigncmd#1#2=#3,#4\@@#5{% + \edef\@dtl@dbname{#5}% \@sDTLifhaskey{#5}{#3}% {% \edef\@dtl@dogetentry{% \noexpand\dtlgetentryfromcurrentrow {\noexpand#1}{\dtlcolumnindex{#5}{#3}}}% \@dtl@dogetentry - \ifx#1\dtlnovalue + \ifdefequal{#1}{\dtlnovalue}% + {% \@@dtl@setnull{#1}{#3}% - \fi + }% + {}% \global\let#1=#1\relax }% {% @@ -684,6 +722,9 @@ \fi \fi } +\newcommand*{\DTLifnullorempty}[3]{% + \ifdefempty{#1}{#2}{\DTLifnull{#1}{#2}{#3}}% +} \def\@dtlnovalue{Undefined Value} \def\dtlnovalue{\@dtlnovalue} \newcommand*{\DTLgetkeydata}{% @@ -1237,7 +1278,7 @@ {% \refstepcounter{DTLrow}% \global\c@DTLrow=\c@DTLrow\relax - \gdef\@dtl@dbname{#2}% + \xdef\@dtl@dbname{#2}% \global\advance\dtlforeachlevel by 1\relax \ifnum\dtlforeachlevel>3\relax \PackageError{datatool}{\string\DTLforeach\space nested too @@ -1391,6 +1432,7 @@ {% \refstepcounter{DTLrow}% \global\c@DTLrow=\c@DTLrow + \xdef\@dtl@dbname{#2}% \global\advance\dtlforeachlevel by 1\relax \ifnum\dtlforeachlevel>3\relax \PackageError{datatool}{\string\DTLforeach\space nested too @@ -2108,12 +2150,12 @@ } \newcommand*{\@dtlsumforkeys}[4][]{% \def#4{0}% - \@for\@dtl@dbname:=#2\do{% - \@sDTLforeach{\@dtl@dbname}% + \@for\@dtl@db@name:=#2\do{% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -2152,12 +2194,12 @@ \newcommand*{\@dtlmeanforkeys}[4][]{% \def#4{0}% \@dtl@elements=0\relax - \@for\@dtl@dbname:=#2\do{% - \@sDTLforeach{\@dtl@dbname}% + \@for\@dtl@db@name:=#2\do{% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -2214,12 +2256,12 @@ \@dtlmeanforkeys[#1]{#2}{#3}{\dtl@mean}% \def#4{0}% \@dtl@elements=0\relax - \@for\@dtl@dbname:=#2\do{% - \@sDTLforeach{\@dtl@dbname}% + \@for\@dtl@db@name:=#2\do{% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -2292,12 +2334,12 @@ } \newcommand*{\@dtlminforkeys}[4][]{% \def#4{}% - \@for\@dtl@dbname:=#2\do{% - \@sDTLforeach{\@dtl@dbname}% + \@for\@dtl@db@name:=#2\do{% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -2348,12 +2390,12 @@ } \newcommand*{\@dtlmaxforkeys}[4][]{% \def#4{}% - \@for\@dtl@dbname:=#2\do{% - \@sDTLforeach{\@dtl@dbname}% + \@for\@dtl@db@name:=#2\do{% + \@sDTLforeach{\@dtl@db@name}% {#1}% assignment list {% \@for\@dtl@key:=#3\do{% - \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@dbname}{\@dtl@key}% + \@sdtl@getcolumnindex{\@dtl@col}{\@dtl@db@name}{\@dtl@key}% \dtlcurrentrow=\expandafter{\dtl@thisrow}% \dtlgetentryfromrow{\DTLthisval}{\@dtl@col}{\dtlcurrentrow}% \expandafter\ifthenelse\expandafter{\@dtl@cond}% @@ -2972,6 +3014,23 @@ database}{}% }% } +\newcommand*{\DTLloaddbtex}[2]{% + \IfFileExists{#2}% + {% + \input{#2}% + \ifdef#1% + {% + \PackageError{datatool}{Command \string#1\space is already defined}% + {}% + }% + {% + \let#1\dtllastloadeddb + }% + }% + {% + \PackageError{datatool}{File `#2' doesn't exist.}{}% + }% +} \newread\@dtl@read \newcount\dtl@entrycr \define@boolkey{loaddb}[dtl]{noheader}[true]{} -- cgit v1.2.3