I am looking for a way to get at the identifier for a variable and somehow automatically put that in another string variable?
Let's say we have:
def VariableA as string
VariableA = "abcd"
ShowVarData("VariableA", VariableA)
sub ShowVarData(VarID as string, VarValue as string)
BoxData$ = VarID + " = " + VarValue
messagebox (null, BoxData$, "SomeTitle")
endsub
If we run the above code it will display the VariableId and the VariableValue in the message box.
Is there a way to only pass in VariableA into a revised ShowVarData sub and have it automatically inspect for the variable identifier?
Thanks...Archie
The name of the variable only exisits in your source code. Once it is compiled into an executable the name isn't there anymore, it is just the address of memory.
Except of course in debug mode where global variables are actually named in the debug segment of the executable. The names, however, are only accessable by a debugger and not by your code.
Paul.
Thanks...Paul
Archie, depending on what you are actually doing with the variable and its value, you might be able to use a dictionary (associative array), and work the key/value pairs from that. Then, there's always pointers! ::)
Declare a local var in the subroutine and return the value.
In the calling section set the value = the return code.
You would only need pass the initialue value once to the subroutine.
string a;
string a1;
.......
a = "ABC";
a1 = subcall(a);
a = a1;
}
sub subcall(string b) string {
b = b + "cde";
return(b);
}
Jerry, I actually used the associative array technique before my post. It works pretty good.
Larry, I am not following you code? Is it in Aurora, rather than eBASIC?