Solved

How to get the name of function or method name that is executing

Posted on 2011-03-02
4
368 Views
Last Modified: 2012-05-11
I am doing some common logging within a large series of funtions and methods and was wondering if there is an easy way to determine the name of the current function/method while executing? Currently I set a const cTag = 'ThisFunction' at the beginning of the function/method and then use cTag in my common logging statements. I was curious if there is a better way to identify the function/method.
Thanks
0
Comment
Question by:softbreeze
4 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 250 total points
Comment Utility
I believe your method is the only possible way to get the name of the executing function:

function ThisFunction():Datatype;
begin
  HoldThenameOfTheFunction:='ThisFunction';
...
end;

Simply because functions' names are not compiled into the exe program.
0
 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 250 total points
Comment Utility
The only way to achieve this, is to define a global variable which holds the name of the currently excuted function.

So there is no better way and your approach is definitely the right one...
0
 
LVL 22

Expert Comment

by:mnasman
Comment Utility
JclDebug unit has function called ProcByLevel, you can download it from JCL website
0
 
LVL 1

Author Closing Comment

by:softbreeze
Comment Utility
Thank you
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now