Current class method name as string

Viewed 1980

I'm wondering if there is a way with Object Pascal to get the name of the method that is currently being executed.

procedure SomeClass.SomeMethod(SomeArgs...);
begin
    { This should print 'This method name is: SomeMethod' }
    WriteLn('This method name is: ' + ???);
end;

Looks like TObject got something similar to what I need in description but I can't make it work.

 public class function TObject.MethodName(address: pointer): shortstring;

Is that the way I should go ?
If I try MethodName(self), it always returns an empty string.
How to get the pointer of the method in a class?

1 Answers
Related