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

Last change on this file since 386 was 386, checked in by smasson, 15 years ago

3 small bugfix

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