Get current method name?

BlitzMax Forums/BlitzMax Programming/Get current method name?

DavidDC(Posted 2008) [#1]
Is it possible to get the name of the current method/function that is running using reflection? If so how?

To clarify
Method GreatMethod()
 
  Print "Method name " +AmazingGetMethodNameFunction()

End Method


Would return: "Method name GreatMethod"

Thanks!


tonyg(Posted 2008) [#2]
I can't see how this can be done other than the obvious :
method greatmethod()
  print "Method name greatmethod()"
end method



Dreamora(Posted 2008) [#3]
There is no reason to know from within which method you call through reflection, as you ARE within the method and know it actually.

Reflection is only needed if you have an object and want to know what functionality it offers.


DavidDC(Posted 2008) [#4]
That's fine - it wasn't a big issue, just wondered if it was possible. I was looking for a way to make my error logging routines more generic. In the same vein, it would have been especially nice if I could have used reflection to offer up the name of the caller (ie, the method that called this method).


tonyg(Posted 2008) [#5]
If you create a debuglog system which adds a 'Function/method nnn entered' and 'Function/method nnn exited' you can get a debug trace. Maybe a profiler with different levels of support : 1 = Perfo, 2 = Trace, 1+2 = Both?


DavidDC(Posted 2008) [#6]
Yes Tony that's what I've already got. Trying to save some typing and neaten it up, that's all :-)

Perhaps some pre-processor/macro system would serve me better here, but I'm not quite sure I'd like to go there at this point.


tonyg(Posted 2008) [#7]
As long time ago I used that method to add statements to the Bmax source and got some really good information on the workflow.
There is another thread somewhere asking if it can be added to the IDE (or somebody's IDE).