I am using \str_if_eq:xxTF{\A}{\Target}{<true>}{<false} to execute the <true> or <false> code if \A=\Target.
What is the list version equivalent of this?
So I am looking for something such as
\str_if_in_list:xxTF{\A}{\TargetList}{<true>}{<false}
which executes the appropriate <true>/<false> if A is in the list (CSV) \TargetList?
I have to admit I have not tried for too long on this as I really can't read expl3 syntax yet, but a few of the macros presented at Using Expl3 token-list variables where token lists are called for looked interesting, but I was not able to get them to work.
So, in the MWE below, by changing \GetTexFilePath and \GetTexFilePathExpandable the last three lines should not have an xxx in the directory path.
The current output is:

Notes:
- The
\TargetListis always a macro that contains the list. - The source of the comparison is usually a value declared with
\newtoksas per the MWE below (not sure if that matters).
References:
Before people get the wrong idea and think that I actually understand some expl3 syntax, here is where that code originated from:
Possible clue to solution:
Code:
\documentclass{article}
\usepackage{xparse}
\newcommand{\NotSpecialDirectory}{foo}
%% These directories should never have an "xxx" in the path.
%% The values here do NOT change at run time.
%% https://tex.stackexchange.com/questions/46323/how-to-expand-values-stored-in-a-token-defined-by-newtoks
\protected\def\SpecialDirectory{AAA}
\protected\def\SpecialDirectoryB{BBB}
\protected\def\SpecialDirectoryC{CCC}
%% The list of members here do NOT change at run time.
\newcommand{\ListOfSpecialDirectories}{%
\SpecialDirectory,%
\SpecialDirectoryB,%
\SpecialDirectoryC,% <-- would prefer to be allowed extra comma here, but
% can do without that if it adds too much complexity
}
\newtoks{\CurrentDirectory}
\ExplSyntaxOn%%% These work fine...
% Determine path: Always #1/xxx#2/#3 unless #1=\SpecialDirectory
\NewDocumentCommand{\GetTexFilePathOld}{m m m}{%
\str_if_eq:xxTF{#1}{\SpecialDirectory}{#1/#2/#3}{#1/xxx#2/#3}%
}%
\DeclareExpandableDocumentCommand{\GetTexFilePathExpandableOld}{m m m}{%
\str_if_eq:xxTF{#1}{\SpecialDirectory}{#1/#2/#3}{#1/xxx#2/#3}%
}%
%%% how do I define these ...
% Determine path: Always #1/xxx#2/#3 unless #1 is in \ListOfSpecialDirectories
% Don't work: % \tl_if_in:nnTF \str_if_in:nnTF, \str_if_in:xxTF
\NewDocumentCommand{\GetTexFilePath}{m m m}{%
\str_if_eq:xxTF{#1}{\ListOfSpecialDirectories}{#1/#2/#3}{#1/xxx#2/#3}%
}%
\DeclareExpandableDocumentCommand{\GetTexFilePathExpandable}{m m m}{%
\str_if_eq:xxTF{#1}{\ListOfSpecialDirectories}{#1/#2/#3}{#1/xxx#2/#3}%
}%
\ExplSyntaxOff
\begin{document}
\noindent\textbf{These work fine:}
\CurrentDirectory={\NotSpecialDirectory}
Should have xxx in path:
\GetTexFilePathOld{\the\CurrentDirectory}{2012}{01},
\GetTexFilePathExpandableOld{\the\CurrentDirectory}{2012}{02}
\CurrentDirectory={\SpecialDirectory}
\medskip\par Should \emph{not} have xxx:
\GetTexFilePathOld{\the\CurrentDirectory}{2013}{03},
\GetTexFilePathExpandableOld{\the\CurrentDirectory}{2013}{04}
\bigskip\hrule\bigskip
\noindent\textbf{Paths starting with AAA, BBB, or CCC should not have an xxxx in the path}
\medskip\par
\CurrentDirectory={\NotSpecialDirectory}
Should have xxx in path:
\GetTexFilePath{\the\CurrentDirectory}{2012}{05},
\GetTexFilePathExpandable{\the\CurrentDirectory}{2012}{06}
\CurrentDirectory={\SpecialDirectory}
\medskip\par Should \emph{not} have xxx:
\GetTexFilePath{\the\CurrentDirectory}{2013}{07},
\GetTexFilePathExpandable{\the\CurrentDirectory}{2013}{08}
\CurrentDirectory={\SpecialDirectory}
\medskip\par Should \emph{not} have xxx:
\GetTexFilePath{\the\CurrentDirectory}{2013}{09},
\GetTexFilePathExpandable{\the\CurrentDirectory}{2013}{10}
\CurrentDirectory={\SpecialDirectoryB}
\medskip\par Should \emph{not} have xxx:
\GetTexFilePath{\the\CurrentDirectory}{2013}{01},
\GetTexFilePathExpandable{\the\CurrentDirectory}{2013}{11}
\bigskip
\end{document}
xin the argument specifiers is fully expandable; you probably are thinking to\str_if_eq_x:nnTF– egreg Feb 23 '13 at 20:13\GetTexFilePathExpandable, or is there really no difference in those two function. I don't recall why, but there was a case where I needed to use\DeclareExpandableDocumentCommandinstead of\NewDocumentCommandto get things to work. Perhaps that was before I changed to using\str_if_eq. Would be happy to eliminate redundant code if those two are identical. – Peter Grill Feb 23 '13 at 20:17\str_if_eq_x:nnTFin\GetTexFilePathOldor\GetTexFilePathExpandablebreaks things as is the case with this MWE. Re your second comment: I am using these macros to determine where appropriate files should be, test to see if they exist, add links to them, and perhaps even\includethem (after similarly generating the appropriate file name and adding an extension based on the context. – Peter Grill Feb 23 '13 at 20:25\GetTexFilePathalways going to be a macro? 2) Do you want to detect the macro names that contain the directories (i.e.\SpecialDirectory) or their expansion (i.e.AAA)? – cgnieder Feb 23 '13 at 20:29\ListOfSpecialDirectoriesand the\protected\defs that it uses does not change at run time, it is a fixed list with fixed value upon start up. However, the first parameter to\GetTexFilePathcan change during compilation at different points in the document. – Peter Grill Feb 23 '13 at 20:34\protectedthey won't be expanded in any test using anxtype argument (i.e. an\edef)! – cgnieder Feb 23 '13 at 21:01\str_if_eq:xxTFmacro works for me, I just need something with identical behavior except that instead of comparing a string it searches for a matching member in a CSV list. The current solution is not matching in functionality of\str_if_eq:xxTF. – Peter Grill Feb 24 '13 at 05:31\deffor use in this case. – Peter Grill Feb 24 '13 at 05:48