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

Last change on this file since 277 was 260, checked in by pinsard, 17 years ago

only uppercase between <proidl>...</proidl> in perspective of links to /usr/local_macosx/idl/idl_6.2/idl_6.2/

  • 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 <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; IDL> print, routine_name()
25;  /usr1/com/smasson/IDL_RD/UTILITAIRE/report.pro
26;  IDL> print, routine_name(1)
27;  /usr1/com/smasson/IDL_RD/PLOTS/DIVERS/determineminmax.pro
28;  IDL> print, routine_name(2)
29;  /usr1/com/smasson/IDL_RD/PLOTS/DESSINE/plt.pro
30;  IDL> print, routine_name(3)
31;  $MAIN$
32;  IDL> print, routine_name(4)
33;  $MAIN$
34;
35; @history
36; Sebastien Masson (smasson\@lodyc.jussieu.fr)
37;                      21/10/1999
38;
39; @version
40; $Id$
41;
42;-
43;
44FUNCTION routine_name,  pilingnum
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.