Im trying to get a variable value through reflection.
There is some discussion here;
www.b4x.com
Based on that thread I can access global variables but I cant access local variables. Is there any way to access local variables within a sub? This is just test code but ultimately the variable name could be anything and wouldnt be hard coded.
There is some discussion here;
Help! Getting and using the name of a variable/array?
Hi guys! This might be hard to explain, but I'll do my best. Consider the following pseudo-code: Dim a, b, c, d, e, f, g, ... As Int GetUserInput("Which variable? ", VarName) SetVar(VarName, 10) 'Output: '(c = 0) 'Which variable? c '(c = 10) How can I do this without having to do this with...

Based on that thread I can access global variables but I cant access local variables. Is there any way to access local variables within a sub? This is just test code but ultimately the variable name could be anything and wouldnt be hard coded.
B4X:
Sub Class_Globals
Dim bob As String = "Hello"
End Sub
Public Sub Initialize
End Sub
Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim bob2 As String = "Goodbye"
Dim jo As JavaObject = Me
Log(jo.GetField("_bob")) ' Works
Log(jo.GetField("_bob2")) ' Does not work
resp.write("End")
End sub