Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/~mperrin/software/sources/getmyname.pro
Дата изменения: Tue Aug 12 02:54:07 2008
Дата индексирования: Sat Mar 1 15:02:44 2014
Кодировка:

Поисковые слова: m 103
;+
; FUNCTION: getmyname
;
; PURPOSE:
; Returns the name and file path to the source code of the calling
; procedure
; NOTES:
; In other words, if you're executing FOO from /some/path/foo.pro
; then
; getmyname, name,path
; sets name="FOO" and path="/some/path/foo.pro"
;
; INPUTS:
; KEYWORDS:
; dir outputs directory not including file name
; OUTPUTS:
; name name of calling procedure
; path path to file containing calling procedure
;
; HISTORY:
;
;-

PRO getmyname,name,path,dir=dir

help,call=call
caller=call[1] ; the thing which called this procedure

if caller eq "$MAIN$" then begin
name="$MAIN$"
path=""
return
endif

; a typical line returned by help,call looks like:
;TMP

sp=strpos(caller," ")
paren=strpos(caller,"(")

name=strmid(caller,0,sp)
path=strmid(caller,sp+2,paren-sp-2)

progname = strlowcase(name)+".pro"
nameloc = strpos(caller,progname)



parts = strsplit(path, '/')
dir = strmid(path,0,parts[n_elements(parts)-1]-1)


end