如何在Delphi 7中获取当前方法的名称? [英] How to get current method's name in Delphi 7?

查看:226
本文介绍了如何在Delphi 7中获取当前方法的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法知道我目前的方法的名称?



所以:

 程序TMyObject.SomeMethod(); 
begin
Writeln('我的名字是:'+< hocus pocus>);
结束

将产生此输出:



code>我的名字是:SomeMethod

解决方案

JCL 是免费的,具有此功能。它取决于堆栈跟踪可以做多少以及调试信息的数量。



JclDebug.pas



函数FileByLevel(const Level:Integer = 0):string;

 
function ModuleByLevel(const Level:Integer = 0):string;
函数ProcByLevel(const Level:Integer = 0):string;
函数LineByLevel(const Level:Integer = 0):整数;


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

解决方案

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;

这篇关于如何在Delphi 7中获取当前方法的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆