views:

910

answers:

1

Is there any way to know the name of a method I'm currently in?

So that:

procedure TMyObject.SomeMethod();
begin
  Writeln('my name is: ' + <hocus pocus>); 
end;

would produce this output:

my name is: SomeMethod

+17  A: 

JCL is free and has functions for that. It does depend on how well a stack trace can be made and how much debug information is present.

JclDebug.pas

function FileByLevel(const Level: Integer = 0): string;
function ModuleByLevel(const Level: Integer = 0): string;
function ProcByLevel(const Level: Integer = 0): string;
function LineByLevel(const Level: Integer = 0): Integer;
Lars Truijens
I'll add this simply cannot be done without debug info of some kind.
Craig Stuntz