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}{type=integer} |
---|
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 | ; @todo |
---|
37 | ; replace str_sep by the non obsolete routine strsplit |
---|
38 | ; |
---|
39 | ; @history |
---|
40 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
41 | ; 21/10/1999 |
---|
42 | ; |
---|
43 | ; @version |
---|
44 | ; $Id$ |
---|
45 | ; |
---|
46 | ;- |
---|
47 | FUNCTION routine_name, pilingnum |
---|
48 | ; |
---|
49 | compile_opt idl2, strictarrsubs |
---|
50 | ; |
---|
51 | help, /traceback, output = name |
---|
52 | |
---|
53 | IF !d.name EQ 'WIN' THEN BEGIN |
---|
54 | name[0] = '% ' + name[0] |
---|
55 | FOR i = 1, n_elements(name)-1 DO BEGIN |
---|
56 | IF strmid(name[i], 0, 1) EQ ' ' THEN name[i] = '%' + name[i] |
---|
57 | ENDFOR |
---|
58 | ENDIF |
---|
59 | |
---|
60 | name = strtrim(name, 1) ; we remove blanks at the beginning of lines and |
---|
61 | ; we put elements of the vector stuck ones with |
---|
62 | ; each others to make an unique string. |
---|
63 | allnames = '' |
---|
64 | for i = 0, n_elements(name)-1 do allnames = allnames+name[i] |
---|
65 | ; |
---|
66 | name = str_sep(allnames, '%') ; we cut it out again. |
---|
67 | name = strtrim(name, 2) ; we remove blanks in front of and behind |
---|
68 | name = strcompress(name) ; we compress blanks |
---|
69 | ; we do not hold back the two first elements who are a blank and the line concerning |
---|
70 | ; routine_name. |
---|
71 | name = name[2: n_elements(name)-1] |
---|
72 | ; we choose the line which concern us. |
---|
73 | if NOT keyword_set(pilingnum) THEN pilingnum = 0 |
---|
74 | if pilingnum GE n_elements(name) THEN BEGIN |
---|
75 | return, '$MAIN$' |
---|
76 | ENDIF |
---|
77 | name = name[pilingnum] |
---|
78 | if strpos(name, '$MAIN$') NE -1 THEN BEGIN |
---|
79 | return, '$MAIN$' |
---|
80 | ENDIF |
---|
81 | name = str_sep(name, ' ') |
---|
82 | if n_elements(name) LT 3 THEN BEGIN |
---|
83 | name = name[0] |
---|
84 | ENDIF ELSE BEGIN |
---|
85 | name = 'L.'+name[1]+' '+name[2] |
---|
86 | ENDELSE |
---|
87 | ; |
---|
88 | return, name |
---|
89 | end |
---|