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

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

header improvements + xxx doc

  • 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;
17; @returns
18; a string giving either the full name of the routine (with the path) or
19; '$MAIN$'
20;
21; @restrictions
22; This function use the keyword OUTPUT in help.pro and it is specified
23; in the online help that the return syntax of this word can change in
24; function of the version of the code. This version works with IDL 5.2.
25;
26; @examples
27; IDL> print, routine_name()
28;  /usr1/com/smasson/IDL_RD/UTILITAIRE/report.pro
29;  IDL> print, routine_name(1)
30;  /usr1/com/smasson/IDL_RD/PLOTS/DIVERS/determineminmax.pro
31;  IDL> print, routine_name(2)
32;  /usr1/com/smasson/IDL_RD/PLOTS/DESSINE/plt.pro
33;  IDL> print, routine_name(3)
34;  $MAIN$
35;  IDL> print, routine_name(4)
36;  $MAIN$
37;
38; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
39;                      21/10/1999
40;
41; @version $Id$
42;
43;-
44;------------------------------------------------------------
45;------------------------------------------------------------
46;------------------------------------------------------------
47FUNCTION routine_name,  pilingnum
48;
49;
50  compile_opt idl2, strictarrsubs
51;
52  help,  /traceback, output = name
53  name = strtrim(name, 1)       ; we remove blanks at the beginning of lines and
54;                               we put elements of the vector stuck ones with
55;                               each others to make an unique string.
56  allnames = ''
57  for i = 0, n_elements(name)-1 do allnames = allnames+name[i]
58;
59  name = str_sep(allnames, '%') ; we cut it out again.
60  name = strtrim(name, 2)     ; we remouve blanks in front of and behind
61  name = strcompress(name)      ; we compress blanks
62; we do not hold back the two first elements who are a blanck  and the line concerning
63; routine_name.
64  name = name[2: n_elements(name)-1]
65; we choose the line which concern us.
66  if NOT keyword_set(pilingnum) then pilingnum = 0
67  if pilingnum GE n_elements(name) then return,  '$MAIN$'
68  name = name[pilingnum]
69  if strpos(name, '$MAIN$') NE -1 then return,  '$MAIN$'
70  name = str_sep(name, ' ')
71  if n_elements(name) LT 3  then name = name[0] ELSE name = 'L.'+name[1]+' '+name[2]
72;
73  return, name
74end
Note: See TracBrowser for help on using the repository browser.