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

Last change on this file since 238 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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