comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to obtain the name of the current routine?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
How to obtain the name of the current routine? [message #93420] Mon, 11 July 2016 01:27 Go to next message
enod is currently offline  enod
Messages: 41
Registered: November 2004
Member
Dear all,

I'd like to write the routine name to the output file as header information. Is there a way to get the name of the running routine automatically when it is executed? For example,

pro test1

name_of_routine = get_the_current_routine_name()
; the above function will make
; name_of_routine = 'test1'

end


Thanks a lot!

Cheers,
Yunfeng Tian
Re: How to obtain the name of the current routine? [message #93421 is a reply to message #93420] Mon, 11 July 2016 01:32 Go to previous messageGo to next message
markb77 is currently offline  markb77
Messages: 217
Registered: July 2006
Senior Member
On Monday, July 11, 2016 at 10:27:15 AM UTC+2, Yunfeng Tian wrote:
> Dear all,
>
> I'd like to write the routine name to the output file as header information. Is there a way to get the name of the running routine automatically when it is executed? For example,
>
> pro test1
>
> name_of_routine = get_the_current_routine_name()
> ; the above function will make
> ; name_of_routine = 'test1'
>
> end
>
>
> Thanks a lot!
>
> Cheers,
> Yunfeng Tian

check out "cgwhoami" from the Coyote IDL library

http://github.com/davidwfanning/idl-coyote

Mark
Re: How to obtain the name of the current routine? [message #93422 is a reply to message #93421] Mon, 11 July 2016 01:57 Go to previous messageGo to next message
enod is currently offline  enod
Messages: 41
Registered: November 2004
Member
On Monday, July 11, 2016 at 4:33:04 PM UTC+8, superchromix wrote:
> On Monday, July 11, 2016 at 10:27:15 AM UTC+2, Yunfeng Tian wrote:
>> Dear all,
>>
>> I'd like to write the routine name to the output file as header information. Is there a way to get the name of the running routine automatically when it is executed? For example,
>>
>> pro test1
>>
>> name_of_routine = get_the_current_routine_name()
>> ; the above function will make
>> ; name_of_routine = 'test1'
>>
>> end
>>
>>
>> Thanks a lot!
>>
>> Cheers,
>> Yunfeng Tian
>
> check out "cgwhoami" from the Coyote IDL library
>
> http://github.com/davidwfanning/idl-coyote
>
> Mark

Great!
Thanks!

Best,
Tian
Re: How to obtain the name of the current routine? [message #93424 is a reply to message #93422] Mon, 11 July 2016 02:49 Go to previous messageGo to next message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 07/11/2016 10:57 AM, Yunfeng Tian wrote:
> On Monday, July 11, 2016 at 4:33:04 PM UTC+8, superchromix wrote:
>> On Monday, July 11, 2016 at 10:27:15 AM UTC+2, Yunfeng Tian wrote:
>>> I'd like to write the routine name to the output file as header
>>> information. Is there a way to get the name of the running
>>> routine automatically when it is executed? For example,
>>>
>>> pro test1
>>>
>>> name_of_routine = get_the_current_routine_name()
>>> ; the above function will make
>>> ; name_of_routine = 'test1'
>>>
>>> end
>> check out "cgwhoami" from the Coyote IDL library
>>
>> http://github.com/davidwfanning/idl-coyote
if you haven't loaded coyote library, this will do too:
> help, /traceback, out=out
> name_of_routine=(out[0].split(' '))[2]
if you want to encapsulate it into a function, you'd have to use out[1]
Re: How to obtain the name of the current routine? [message #93437 is a reply to message #93420] Thu, 14 July 2016 20:59 Go to previous message
zacharyanorman is currently offline  zacharyanorman
Messages: 17
Registered: July 2015
Junior Member
The easiest way would be to use the scope_traceback function like this:

pro test
scope = scope_traceback(/structure)

print, scope, /implied_print
end

The last element of the scope variable will contain information regarding the routine you are in. I use scope_traceback to determine the location of my functions or procedures that are being executed. Here is a link to the docs:

http://www.harrisgeospatial.com/docs/SCOPE_TRACEBACK.html
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Weighted standard deviation in IDL
Next Topic: Plotting time as x-axis

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 07:14:46 PDT 2025

Total time taken to generate the page: 0.11545 seconds