• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

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

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.
2 Solutions
I believe your method is the only possible way to get the name of the executing function:

function ThisFunction():Datatype;

Simply because functions' names are not compiled into the exe program.
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...
Mohammed NasmanSoftware DeveloperCommented:
JclDebug unit has function called ProcByLevel, you can download it from JCL website
softbreezeAuthor Commented:
Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now