[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[136] | 3 | ; @file_comments |
---|
[133] | 4 | ; Give us the name of the routine (procedure or function) where we are. |
---|
[2] | 5 | ; |
---|
[224] | 6 | ; @categories |
---|
[157] | 7 | ; Utilities |
---|
[2] | 8 | ; |
---|
[163] | 9 | ; @param PILINGNUM {in}{optional} |
---|
[136] | 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. |
---|
[2] | 12 | ; |
---|
[136] | 13 | ; @returns |
---|
| 14 | ; a string giving either the full name of the routine (with the path) or |
---|
| 15 | ; '$MAIN$' |
---|
[2] | 16 | ; |
---|
[136] | 17 | ; @restrictions |
---|
[260] | 18 | ; This function use the keyword OUTPUT in <proidl>HELP</proidl> and |
---|
[242] | 19 | ; it is specified |
---|
[163] | 20 | ; in the on-line help that the return syntax of this word can change in |
---|
[136] | 21 | ; function of the version of the code. This version works with IDL 5.2. |
---|
| 22 | ; |
---|
| 23 | ; @examples |
---|
[371] | 24 | ; |
---|
| 25 | ; IDL> print, routine_name() |
---|
[2] | 26 | ; /usr1/com/smasson/IDL_RD/UTILITAIRE/report.pro |
---|
[371] | 27 | ; IDL> print, routine_name(1) |
---|
[2] | 28 | ; /usr1/com/smasson/IDL_RD/PLOTS/DIVERS/determineminmax.pro |
---|
[371] | 29 | ; IDL> print, routine_name(2) |
---|
[2] | 30 | ; /usr1/com/smasson/IDL_RD/PLOTS/DESSINE/plt.pro |
---|
[371] | 31 | ; IDL> print, routine_name(3) |
---|
[2] | 32 | ; $MAIN$ |
---|
[371] | 33 | ; IDL> print, routine_name(4) |
---|
[2] | 34 | ; $MAIN$ |
---|
| 35 | ; |
---|
[224] | 36 | ; @history |
---|
| 37 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[2] | 38 | ; 21/10/1999 |
---|
[133] | 39 | ; |
---|
[224] | 40 | ; @version |
---|
| 41 | ; $Id$ |
---|
[133] | 42 | ; |
---|
[2] | 43 | ;- |
---|
[133] | 44 | FUNCTION routine_name, pilingnum |
---|
[2] | 45 | ; |
---|
[114] | 46 | compile_opt idl2, strictarrsubs |
---|
| 47 | ; |
---|
[11] | 48 | help, /traceback, output = name |
---|
[386] | 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 | |
---|
[136] | 57 | name = strtrim(name, 1) ; we remove blanks at the beginning of lines and |
---|
| 58 | ; we put elements of the vector stuck ones with |
---|
[133] | 59 | ; each others to make an unique string. |
---|
[11] | 60 | allnames = '' |
---|
| 61 | for i = 0, n_elements(name)-1 do allnames = allnames+name[i] |
---|
[2] | 62 | ; |
---|
[136] | 63 | name = str_sep(allnames, '%') ; we cut it out again. |
---|
[226] | 64 | name = strtrim(name, 2) ; we remove blanks in front of and behind |
---|
[133] | 65 | name = strcompress(name) ; we compress blanks |
---|
[136] | 66 | ; we do not hold back the two first elements who are a blanck and the line concerning |
---|
| 67 | ; routine_name. |
---|
[11] | 68 | name = name[2: n_elements(name)-1] |
---|
[133] | 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] |
---|
[11] | 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 |
---|
[2] | 78 | end |
---|