I've got a large multi-purpose database and i would like to pick several items in it (using labels) and print them in the given order, not the database order or any entry-related order.
For example, i currently use this code (found on this site, thanks to Peter Grill) :
\documentclass{article}
\usepackage{datatool}
\usepackage{longdata}
\usepackage{filecontents}
\begin{filecontents*}{foo.dat}
Hammer001, Hammer, 1 , 0 , 1 , 10 , 1 , light\\
Hammer002, Hammer, 2 , 0 , 1 , 10 , 1 , heavy\\
Hammer003, Hammer, 3 , 0 , 1 , 10 , 1 , really heavy\\
Longsword001,Longsword, 1 , -1 , 2 , 75 , 2 , one-handed \\
Longsword002,Longsword, 2 , -1 , 2 , 75 , 2 , two-handed \\
Longsword003,Longsword, 3 , -1 , 2 , 75 , 2 , three-handed \\
\end{filecontents*}
\newcommand{\PrintDTLTable}[2]{%
% #1 = database to search
% #2 = list of rowIDs
\begin{enumerate}
\DTLforeach*[\DTLisSubString{#2}{\RowID}]{#1}{%
\RowID=RowID,%
\Label=Label,%
\Cost=Cost,%
\Weight=Weight,%
\Description=Description%
}{%
\item \Label ; Price=\Cost ; Weight=\Weight ; It's very \Description
}%
\end{enumerate}
}%
\begin{document}
\DTLloaddb[noheader,keys={RowID,Label,Cost,Weight,PropA,PropB,PropC,Description}]{myDB}{foo.dat}
\PrintDTLTable{myDB}{Hammer001,Hammer003,Longsword003}
\end{document}
The command
\PrintDTLTable{myDB}{Hammer001,Hammer003,Longsword003}
is doing exactly what i want except that
\PrintDTLTable{myDB}{Hammer003,Longsword003,Hammer001}
would obviously produce the exact same result.
Is there any way to keep the given order ? (sorry for my poor english)