I am trying to dynamically define variables. What I want to do is be able to define a person in the following way \definePerson{MrTestKey}{Mr Test}{0400 000 000}{mr@test.com} and then subsequently call \nameMrTestKey to return "Mr Test", \phoneMrTestKey to return "0400 000 000" and \emailMrTestKey to return "mr@test.com".
This is what I have tried so far... I use the \defineVariable macro so that I can call \nameMrTestKey to return a formatted (\emph) name and \nameMrTestKey* to return an unformatted name.
% To allow (un)formatted variables
% See http://tex.stackexchange.com/questions/51652/remove-formatting/
\usepackage{xparse}
\NewDocumentCommand\defineVariable{mmm}{%
\NewDocumentCommand#1{s}{\IfBooleanTF{##1}{#3}{#2{#3}}}%
}
% \definePerson{key}{name}{phone}{email}
\newcommand\definePerson[4]{%
\defineVariable\name#1{\emph}{#2}
\defineVariable\phone#1{\emph}{#3}%
\defineVariable\email#1{\emph}{#4}%
}




\definePerson[MrTest][name={Mr Test}, phone={...}, email={...}]. For multiple arguments like this, IMHO a key value syntax is easier to remember than the order of the arguments. – Aditya Jul 20 '12 at 13:56