getting the function name

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

getting the function name

Post by AriSilva »

Is there a way to have access to the function´s name that is being executed, similar to getsymbol to acces the proc´s name?
Such as "getfunction()"?
Best
Ari
Best
Ari
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: getting the function name

Post by sherrell »

Hi Ari,

No, sorry, we don't offer that. Is there a reason you need it?

Thanks,
Sherrell
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: getting the function name

Post by AriSilva »

The reason is not that crucial, I can always use a text field to have it.
I use this kind of information mainly to display messages to myself (in the trace function).
Sometimes I use it also to keep track of the program flow and, for a specific reason, I call a function from different other functions and I need to know who called this common function.
In either case I can survive, no problem, the fact is that using something like getfunctionname() produces a neater coding.
Best
Ari
Best
Ari
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: getting the function name

Post by Gregory Martin »

Can you just put this at the top of PROC GLOBAL?
set trace;
In your trace output, you'll be able to see the logic that was executed to get to the point that you're interested in tracking.
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: getting the function name

Post by AriSilva »

sure, I´m using it.
I´m tracking the program using that, but sometimes the routines are similar and by using the trace with the routine name helps me debugging.
Also, when cspro issues an error, like invalid subscript, it points to a proc, not to a function that was called inside the proc, and when you have a proc with several functions, and functions calling another functions it is a little difficult to get the error. Can you pinpoint the function that caused the error instead of the procedure that called it?
Best
Ari
Best
Ari
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: getting the function name

Post by Gregory Martin »

Makes sense. The issue you raise with subscript errors is often brought up by a colleague. You can use "%p" in message text to get the procedure you're in, but as you note, there's no way to get the function name. We'll keep this on our list of feature requests. We would have to fully think it through, because you might also want the entire stack of code you're executing: PROC, function 1, function 2, etc.
Post Reply