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

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

change *.pro file properties (del eof-style, del executable, set keywords Id

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