Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-02
4
Medium Priority
?
376 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 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

916 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