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

Last change on this file since 229 was 226, checked in by pinsard, 17 years ago

corrections of some misspellings in some *.pro

  • 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
38; Sebastien Masson (smasson\@lodyc.jussieu.fr)
39;                      21/10/1999
40;
41; @version
42; $Id$
43;
44;-
45;------------------------------------------------------------
46;------------------------------------------------------------
47;------------------------------------------------------------
48FUNCTION routine_name,  pilingnum
49;
50;
51  compile_opt idl2, strictarrsubs
52;
53  help,  /traceback, output = name
54  name = strtrim(name, 1)       ; we remove blanks at the beginning of lines and
55;                               we put elements of the vector stuck ones with
56;                               each others to make an unique string.
57  allnames = ''
58  for i = 0, n_elements(name)-1 do allnames = allnames+name[i]
59;
60  name = str_sep(allnames, '%') ; we cut it out again.
61  name = strtrim(name, 2)     ; we remove blanks in front of and behind
62  name = strcompress(name)      ; we compress blanks
63; we do not hold back the two first elements who are a blanck  and the line concerning
64; routine_name.
65  name = name[2: n_elements(name)-1]
66; we choose the line which concern us.
67  if NOT keyword_set(pilingnum) then pilingnum = 0
68  if pilingnum GE n_elements(name) then return,  '$MAIN$'
69  name = name[pilingnum]
70  if strpos(name, '$MAIN$') NE -1 then return,  '$MAIN$'
71  name = str_sep(name, ' ')
72  if n_elements(name) LT 3  then name = name[0] ELSE name = 'L.'+name[1]+' '+name[2]
73;
74  return, name
75end
Note: See TracBrowser for help on using the repository browser.