I came across "What is the recommended way to assign a value to a variable and retrieve it for later use?" while trying to figure out how to use PGFKEYS. I'm having trouble, however, figuring out how to make it detect keys that are not set.
MWE:
\documentclass{minimal}
\usepackage{pgfkeys}
\newcommand{\setValue}[1]{\pgfkeys{/variables/#1}}
\newcommand{\getValue}[1]{\pgfkeysvalueof{/variables/#1}}
\newcommand{\declare}[1]{%
\pgfkeys{
/variables/#1.is family,
/variables/#1.unknown/.style = {\pgfkeyscurrentpath/\pgfkeyscurrentname/.initial = ##1}
}%
}
\declare{}
\newcommand{\leftTailA}[1]{%
\declare{@mLT/}
\setValue{@mLT, Label = #1 }
\ifx\getValue{@mLT/Label}\empty
\else
$>$\getValue{@mLT/Label}$<$
\fi
}
\newcommand{\leftTailB}[1]{%
\ifx#1\empty
\else
$>$#1$<$
\fi
}
\pgfkeys{
/distMarkup/.is family, /distMarkup,
default/.style = { leftTailLabel = {} },
leftTailLabel/.estore in = \myLeftTailLabel,
}
\newcommand\distMarkup[1][]{% Note, don't put a space between the , and the #1, why? I don't know.
\pgfkeys{/distMarkup, default,#1}
\ifx\myLeftTailLabel\empty
\else
$>$\myLeftTailLabel$<$
\fi
}
\begin{document}
A: This has a label: \leftTailA{ label number 1 }
A: This has no label: \leftTailA{}
B: This has a label: \leftTailB{ label number 1 }
B: This has no label: \leftTailB{}
MA: This has a label: \distMarkup[leftTailLabel=label number 1]
MA: This has no label: \distMarkup[]
\end{document}
The output from this code sample is:
A: This has a label: > label number 1<
A: This has no label: ><
B: This has a label: > label number 1 <
B: This has no label:
MA: This has a label: >label number 1<
MA: This has no label:
In particular, I don't understand why "A: This has no label" says "><" rather than nothing.
Extra Credit: What does the ##1 do in the \declare declaration?

