In a general programming sense, and certainly in Axure, this shouldn’t be necessary. The name of a variable is known to the program/programmer, and is static. If you plan to reuse it or its purpose changes later on, then it is best to name it accordingly. For example, something like “Username”, “User01” or “temp1” instead of “Johnny”. It is probably easier to just use two global variables, one for your “dynamic name” (e.g., “Johnny” or “Jonny”) and another for the true value (e.g., “10”).
- Global Variable: User01
- Dynamic Name: Johnny
- Default Global Variable value: Johnny;
(set from the Auxre RP menu item Project > Global Variables…)
Using the global variable (setting and getting) becomes more cumbersome (so again, likely easier to just use two global variables instead) but maybe not too bad with judicious copy&paste… You can make use of the substring() and/or slice() functions (more or less interchangeably.)
- To set the true value for “Johnny” to “10” use:
Set Variable Value
User01 to “[[ User01.slice(0, User01.indexOf(’;’)+1) + ‘10’ ]]”
- To get the true value, use the expression:
[[ User01.slice(User01.indexOf(’;’)+1) ]]
- To set the text of a widget named, MyWidget, to the dynamic variable name use:
MyWidget to [[ User01.substring(0, User01.indexOf(’;’)) ]]
// the semicolon ( ; ) is used as a delimiter between the dynamic name and true value. You can replace it with any char or string–just be consistent with whatever you use and make sure it is not used as part of your dynamic name or any possible true value.
Here’s a quick demo: Dynamic Global Variable Names.rp (55.2 KB)