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 | FUNCTION routine_name, pilingnum |
---|
44 | ; |
---|
45 | compile_opt idl2, strictarrsubs |
---|
46 | ; |
---|
47 | help, /traceback, output = name |
---|
48 | name = strtrim(name, 1) ; we remove blanks at the beginning of lines and |
---|
49 | ; we put elements of the vector stuck ones with |
---|
50 | ; each others to make an unique string. |
---|
51 | allnames = '' |
---|
52 | for i = 0, n_elements(name)-1 do allnames = allnames+name[i] |
---|
53 | ; |
---|
54 | name = str_sep(allnames, '%') ; we cut it out again. |
---|
55 | name = strtrim(name, 2) ; we remove blanks in front of and behind |
---|
56 | name = strcompress(name) ; we compress blanks |
---|
57 | ; we do not hold back the two first elements who are a blanck and the line concerning |
---|
58 | ; routine_name. |
---|
59 | name = name[2: n_elements(name)-1] |
---|
60 | ; we choose the line which concern us. |
---|
61 | if NOT keyword_set(pilingnum) then pilingnum = 0 |
---|
62 | if pilingnum GE n_elements(name) then return, '$MAIN$' |
---|
63 | name = name[pilingnum] |
---|
64 | if strpos(name, '$MAIN$') NE -1 then return, '$MAIN$' |
---|
65 | name = str_sep(name, ' ') |
---|
66 | if n_elements(name) LT 3 then name = name[0] ELSE name = 'L.'+name[1]+' '+name[2] |
---|
67 | ; |
---|
68 | return, name |
---|
69 | end |
---|