I am getting a value by a command. Now I am temporarily changing a saved variable which changes the command output. After I finished some code I want to reset the stored value if the value before the temporare code was 1.
My example can be stripped down to:
\newcommand{\storedvalue}{1}
\newcommand{\getstoredvalue}{\storedvalue}
\newcommand{\resetstoredvalue}{Resetting}
Some text
\let\oldvalue\protect\getstoredvalue
\renewcommand{\storedvalue}{0}
Some text which needs the stored value to be changed
\ifnum\numexpr\oldvalue>0%
\resetstoredvalue{}%
\fi%
Of course the \getstoredvalue and the \resetstoredvalue are a lot more complicated.
I tried to use \protect. This will return the correct value, not the command. But I get Missing number, treated as zero in my if-clause.
I think this is a rather easy question. But I did not find a solution by googling. Also this may be because I was looking for the wrong searching term.
I hope somebody can help me or post a website where I can find the solution myself.

\edefworks perfectly. Thank you very much. I cannot save the\storedvaluebecause in my real code the command is not simply returning the value. - One more question: Why should I leave the%after the0? I read this very often so I was thinking this is the "convention" to do it. – miile7 Jun 05 '18 at 10:33