Re: how to find name of top level program [message #58023] |
Mon, 14 January 2008 10:34 |
Douglas G. Dirks
Messages: 10 Registered: October 2006
|
Junior Member |
|
|
Vince Hradil wrote:
> On Jan 11, 2:04 pm, Enemy of the State <mfquig...@wisc.edu> wrote:
>> Greetings IDL comrades!
>>
>> I suspect this is an overly simple question but I'm stumped.....
>>
>> What I would like to do is to find out the name of the top level IDL
>> procedure so that I can put it via xyouts on the plots it produces:
>>
>> pro junk,xxx
>>
>> ... various other routines and functions called to do one thing or
>> another ...
>>
>> plot, some_vector
>>
>> .... something magical happens here so that I have a variable (eg,
>> program_name)
>> that tells me the name of the program that produced this plot
>> is "junk"
>>
>> sub_xyouts,.1,.1,' name of program that produced this plot is
>> '+program_name,/normal
>>
>> return
>> end
>>
>> It seems like the help command would do this somehow, but darn if I
>> can figure out how it might be done.
>>
>> Thanks!
>>
>> Mark
>
> Here's what I do:
> help, /recall_commands, output=cmds
> cmdline = strmid(cmds[1],2)
Or, if you have IDL 6.2 or later, the same basic idea in a single line:
topRoutine=(SCOPE_TRACEBACK(/STRUCTURE))[1].Routine
(It's element 1 of the array returned by SCOPE_TRACEBACK because
IDL considers $MAIN$ to be the top of the call stack.)
Doug
----------------
Douglas G. Dirks
IDL Documentation Group * ITT Visual Information Solutions
4990 Pearl East Circle * Boulder, CO 80301
ddirks@ittvis.com
|
|
|
Re: how to find name of top level program [message #58046 is a reply to message #58023] |
Fri, 11 January 2008 12:56  |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On Jan 11, 2:04 pm, Enemy of the State <mfquig...@wisc.edu> wrote:
> Greetings IDL comrades!
>
> I suspect this is an overly simple question but I'm stumped.....
>
> What I would like to do is to find out the name of the top level IDL
> procedure so that I can put it via xyouts on the plots it produces:
>
> pro junk,xxx
>
> ... various other routines and functions called to do one thing or
> another ...
>
> plot, some_vector
>
> .... something magical happens here so that I have a variable (eg,
> program_name)
> that tells me the name of the program that produced this plot
> is "junk"
>
> sub_xyouts,.1,.1,' name of program that produced this plot is
> '+program_name,/normal
>
> return
> end
>
> It seems like the help command would do this somehow, but darn if I
> can figure out how it might be done.
>
> Thanks!
>
> Mark
Here's what I do:
help, /recall_commands, output=cmds
cmdline = strmid(cmds[1],2)
|
|
|
Re: how to find name of top level program [message #58047 is a reply to message #58046] |
Fri, 11 January 2008 12:46  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Enemy of the State writes:
> I suspect this is an overly simple question but I'm stumped.....
>
> What I would like to do is to find out the name of the top level IDL
> procedure so that I can put it via xyouts on the plots it produces:
I use ProgramRootDir:
http://www.dfanning.com/programs/programrootdir.pro
This program is EXTREMELY useful to me in locating files
in various subdirectories of the main "project" directory
when I am writing code that I am distributing to others.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|