Solved

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

Posted on 2011-03-02
4
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 250 total points
ID: 35024312
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
ID: 35024612
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:Mohammed Nasman
ID: 35025574
JclDebug unit has function called ProcByLevel, you can download it from JCL website
0
 
LVL 1

Author Closing Comment

by:softbreeze
ID: 35026191
Thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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