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

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

english and nicer header (1)

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
RevLine 
[2]1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
[133]6; @file_comments
7; Give us the name of the routine (procedure or function) where we are.
[2]8;
[133]9; @categories utilities
[2]10;
[133]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.
[2]13;
14;
[133]15; @returns a string giving either the full name of the routine (with the path) or '$MAIN$'
[2]16;
[133]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.
[2]20;
[133]21; @example IDL> print, routine_name()
[2]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;
[133]32; @history Sebastien Masson (smasson@lodyc.jussieu.fr)
[2]33;                      21/10/1999
[133]34;
35; @version $Id$
36;
[2]37;-
38;------------------------------------------------------------
39;------------------------------------------------------------
40;------------------------------------------------------------
[133]41FUNCTION routine_name,  pilingnum
[2]42;
[114]43;
44  compile_opt idl2, strictarrsubs
45;
[11]46  help,  /traceback, output = name
[133]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.
[11]50  allnames = ''
51  for i = 0, n_elements(name)-1 do allnames = allnames+name[i]
[2]52;
[133]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.
[11]58  name = name[2: n_elements(name)-1]
[133]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]
[11]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
[2]68end
Note: See TracBrowser for help on using the repository browser.