Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current method's name in Delphi 7?

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

like image 986
tomazy Avatar asked Aug 19 '09 16:08

tomazy


1 Answers

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; 
like image 51
Lars Truijens Avatar answered Sep 22 '22 06:09

Lars Truijens