Type TCustom
public:
declare function GetName() as string
private:
myname as string
End Type
function TCustom.GetName()
return get_my_symbol_name_somehow(this)
end function
'-------------------------------
dim tcB as TCustom
dim tcA as TCustom
print tcA.GetName() 'would print tcA
I have a define that I can pass a variable name to and it will return it as a string, but that isnt quite what I want. I think I need a way to track variables even if they get reassigned to other variable names in my code. That is to say, i need to know what varaible name they were initialized with. Dont ask why, just entertain me please. Thank you in advance.
Id even be happy with a method that would allow me to put the initial symbol name in a string when the udt is initialized.
Why not record the variable name and it’s address when you declare it. If you pass it byref then @variable will return the original pointer so you can lookup the original name.
Ok so its a little bit complicated but here goes. I have a callback function that gets called by an object. the callback has a single argument that it takes which is a pointer to the calling object. The calling object is part of a shared library and not part of my source. Thats why Its being referenced by pointer.
I have a UDT that acts a Class to encapsulate API calls (in custom methods) that can be used with the object stored at a given pointer (known by a variable stored in the UDT).
When the callback function is called it will receive the pointer to the outside API object, but I need to know which UDT was associated with that pointer when the callback was triggered.
I came across a problem like this interfacing with Lua once. I was trying to make a generic callback to handle different situations. Unless the author of you external library included some means of identifying what structure is passed to the callback, then you are stuck. Symbols do not survive compilation unless somebody deliberately writes code to make it so.
Now if you have the source of the external library?
Funny thing, I was searching the API and found that each object had a generic mapping that will allow me to set/get data by key. So I can assign a generic "Name" property to the object at the pointer. This should solve my problem. Thank you all for the feedback though.