Solved

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

Posted on 2011-03-02
4
373 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

Industry Leaders: 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month6 days, 5 hours left to enroll

626 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