# Accessing a pgfkeys value

Perhaps I am fundamentally misunderstanding what \pgfkeys does, but I would like to use it as a way to store and retrieve data in my tex document. Based on the documentation, I would expext

\pgfkeys{/a/b=my value}
Hi there \pgfkeys{/a/b}!


to insert Hi there my value! into the document. The only way I have managed to get something similar to work is with

\pgfkes{/a/b/.code=#1, /a/b/.default=my value}
Hi there \pgfkeys{/a/b}!


but this definitely seems like improper usage to me...

How can I just set values and retrieve them later?

What you have is essentially correct but you need to set up the key properly first. Once the keys have been defined properly you can use \pgfkeys{/a/b} and \pgfkeysvalueof{/a/b} to access the current value.

For example, the code:

\documentclass{article}
\usepackage{pgfkeys}

\pgfkeys{/a/.is family, /a,
b/.initial=my value
}

\begin{document}

Hi there \pgfkeys{/a/b}''!

\pgfkeys{/a/b=a new value}
You can also use \pgfkeysvalueof{/a/b}''.

\end{document}


produces: