I would like to be able to automatically determine which release of TeXLive that I am running. I sometimes encounter a problem where it is useful to test that the file compiled correctly in an older release first, before trying to debug the problem.
Currently, I have updated my code to use the new features of the the datatool
package as per No room for a new \count with datatool. Along with the datatool
update, I updated all the other packages and am now encountering a problem that at least seemed to have worked properly for over a year now.
But it is not simple to switch back to running the older TeXLive2011 as it does not have the new packages. And of course updating the packages of the 2011 would kind of defeat the purpose of here. :-)
The MWE below runs fine with the latest updated TeXLive2012 (Version 2.13
of datatool
or later). But, in order for this to run with an older release, one needs to manually edit the \def\TeXLiveVersion
version to something other than 2012
.
References:
Notes:
For the MWE to be useful, an older release is required as there is no issue here with the current TeXLive2012. Or, if you have not updated your packages lately and have v2.12 (or older) version of
datatool
package (in which case this won't run unless you manually edit the\TeXLiveVersion
to:\def\TeXLiveVersion{2011}%
Here is an older question where I had a problem with TeXLive2011 (but the file compiled fine with TeXLive2010): Debugging Advice: TeX Capacity Exceeded with TeXLive2011 (but not with TeXLive2010). At that time I had manually changed the preamble, but again that is a case where an automated solution would have been useful.
In case it is not obvious, the actual output of the MWE here is not important. It is a cooked up example to show a case where I need to know which version of TeXLive I am using, and a way to test that the proposed solution of determining the version actually worked.
Code:
\def\TeXLiveVersion{2012}% <--- Don't want to have to manually specify this
\documentclass{article}
\usepackage{datatool}
\usepackage{pgffor}
\usepackage{xstring}
\usepackage{letltxmacro}
%\usepackage{filecontents}% Commented to prevent overwriting MyData.csv
\begin{filecontents*}{MyData.csv}
Directory, Color
../dirB, red
../dirC, yellow
\end{filecontents*}
\LetLtxMacro\MyDTLcleardb{\DTLcleardb}% Default to 2012 and future
\IfEq{\TeXLiveVersion}{2012}{%
}{%
\newif\ifDTLnewdbonload%
\LetLtxMacro\MyDTLcleardb{\DTLdeletedb}%
}%
\begin{document}
\DTLnewdb{MyDB}
\DTLnewdbonloadfalse% don't let \DTLloaddb create a new database
\foreach \x in {1,...,5}{% Read DB numerous times
\typeout{count=\x}%
\MyDTLcleardb{MyDB}% clear database
\DTLloadrawdb[keys={Directory,Color}]{MyDB}{MyData.csv}%
}%
\par\noindent\DTLdisplaydb{MyDB}% Some output to have a PDF
\end{document}