[Solved] Confused with updating a newcommand constant inside a foreach loop

MaxPimento Asks: Confused with updating a newcommand constant inside a foreach loop
I am confused on how to update a “constant” construct inside a foreach loop, the similar questions on here don’t directly address the issue I am facing and I’m not experimented enough (yet! ;) in LaTeX to figure it out by myself.

I believe the issue arise from the const definition. I have tested replacing globaledef by glet,csglet, gletcs and csgletcs (quite blindly, but was suggested in a couple of answers on here) to no avail.

I’d appreciate any help on this matter,

Thanks!

Code:
documentclass{article}

usepackage{pgffor}
usepackage[nomessages]{fp}

% ---- Helper function: easily add values to variables
%      Taken from a reply on stackoverflow that I can't find back...
%.     Works like so const{VariableName}{value} ex: const{CoolVariable}{5}
%.     and can then be called with CoolVariable
%.     and can be updates with const{CoolVariable}{CoolVariable+10}
newcommandconst[3][0]{%
   globaledeftemporary{round(#3}%
   expandafterFPevalcsname#2expandafterendcsname
       expandafter{temporary:#1)}%
}


% ---- Set dummy variable 
const{MyVariable}{1}

% ---- I want to loop over a list of keywords with the name of "MyVariable"
%.     Only one here for example.
newcommandMyVariableList{MyVariable}

% ---- Start the loop and update values of constants in MyVariableList
foreach variable in MyVariableList{
   % ---- This updates the variable MyVariable correctly
   const{csname variableendcsname}{csname variableendcsname +20}
   
   % ---- Values of MyVariable changes within the loop
   MyVariable inside the loop: csname variableendcsname
}

begin{document}

MyVariable outisde the loop: 
% ---- But not outside of it 
MyVariable

end{document}


ExampleOutput

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.