source: trunk/SRC/Utilities/routine_name.pro @ 199

Last change on this file since 199 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; Give us the name of the routine (procedure or function) where we are.
8;
9; @categories
10; Utilities
11;
12; @param PILINGNUM {in}{optional}
13; A whole number which give us how many level we have to reascend
14; in the piling up of routines and subroutines to find the looked for routine.
15;
16; @returns
17; a string giving either the full name of the routine (with the path) or
18; '$MAIN$'
19;
20; @restrictions
21; This function use the keyword OUTPUT in help.pro and it is specified
22; in the on-line help that the return syntax of this word can change in
23; function of the version of the code. This version works with IDL 5.2.
24;
25; @examples
26; IDL> print, routine_name()
27;  /usr1/com/smasson/IDL_RD/UTILITAIRE/report.pro
28;  IDL> print, routine_name(1)
29;  /usr1/com/smasson/IDL_RD/PLOTS/DIVERS/determineminmax.pro
30;  IDL> print, routine_name(2)
31;  /usr1/com/smasson/IDL_RD/PLOTS/DESSINE/plt.pro
32;  IDL> print, routine_name(3)
33;  $MAIN$
34;  IDL> print, routine_name(4)
35;  $MAIN$
36;
37; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
38;                      21/10/1999
39;
40; @version $Id$
41;
42;-
43;------------------------------------------------------------
44;------------------------------------------------------------
45;------------------------------------------------------------
46FUNCTION routine_name,  pilingnum
47;
48;
49  compile_opt idl2, strictarrsubs
50;
51  help,  /traceback, output = name
52  name = strtrim(name, 1)       ; we remove blanks at the beginning of lines and
53;                               we put elements of the vector stuck ones with
54;                               each others to make an unique string.
55  allnames = ''
56  for i = 0, n_elements(name)-1 do allnames = allnames+name[i]
57;
58  name = str_sep(allnames, '%') ; we cut it out again.
59  name = strtrim(name, 2)     ; we remouve blanks in front of and behind
60  name = strcompress(name)      ; we compress blanks
61; we do not hold back the two first elements who are a blanck  and the line concerning
62; routine_name.
63  name = name[2: n_elements(name)-1]
64; we choose the line which concern us.
65  if NOT keyword_set(pilingnum) then pilingnum = 0
66  if pilingnum GE n_elements(name) then return,  '$MAIN$'
67  name = name[pilingnum]
68  if strpos(name, '$MAIN$') NE -1 then return,  '$MAIN$'
69  name = str_sep(name, ' ')
70  if n_elements(name) LT 3  then name = name[0] ELSE name = 'L.'+name[1]+' '+name[2]
71;
72  return, name
73end
Note: See TracBrowser for help on using the repository browser.