[Closed] Get name of a variable as string?
Hiya,
Is there a way to get a name of a variable as a string?
So for example GetName(MyVariable) would return “MyVariable”
This would be very handy for saving information down to disk.
/Andreas
Nope, that doesn’t work. That will convert the value of the variable into a string. But I want to get the actual variable name.
for example
test=10
getname(test) will return “test”
if i write:
test as string it will return “10”
I would use this to save variable values into ini files.
/Andreas
I don’t see the usefulness of this. If you could write getname(test), you would HAVE TO TYPE IN test, so how difficult it is the write “test” instead?
Where are you getting the variables from? How are you getting the variables? Is it procedural approach or do you explicitly write each variable being saved to INI file?
Hiya bobo,
Here is an exact example of how I do right now:
IniClass.Update “Lock” &Lock saveOrLoad
Notice that I first have to write the name of the variable “Lock”
then I send in the variable Lock. The SaveOrLoad is either true or false if it loads or saves the file into an ini file.
What I would like to do is just skip the first variable so it says this instead
IniClass.Update &Lock saveOrLoad
I must have the name when I write in the ini file to identify the variable, it says something like this in the ini file:
LockWindows=true
I load/save them manually. Since I’m saving/loading hundreds of variables it would be nice to save some manual typing, but you are right it’s not extremely important. However I can imagine other uses, like debugging.
/Andreas
Hey Andreas,
Shouldn’t this work?
((#x)as string)
where x is the variable you want the name of as a string