;+ ; NAME: ; who_am_i ; PURPOSE: ; Returns file name of procedure calling this function ; CATEGORY: ; gen/idl/toolbox/files ; CALLING SEQUENCE: FUNCTION who_am_i, env=env, directory=directory, procedure=procedure, caller=caller ; INPUTS: ; (none) ; OPTIONAL INPUTS: ; /procedure if set, the name of the calling IDL procedure is returned ; (in lowercase!!) ; /directory if set, only the directory of the calling function is returned ; env=env scalar; type: string ; name of environment variable ; if full file name starts with this environment ; variable is replaced by ~ in the returned value ; OUTPUTS: ; Result scalar; type: string ; full path to the file calling this function ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, GetFileSpec ; PROCEDURE: ; Uses IDL help, /call command ; MODIFICATION HISTORY: ; SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, directory , /key InitVar, procedure , /key InitVar, caller , /key help, calls=calls CASE 1 OF procedure: BEGIN me = calls[1] ; Calling procedure name and file name me = strmid(me, 0, strpos(me,' <')) me = strlowcase(me) END caller: BEGIN me = calls[2] IF strpos(me,' <') NE -1 THEN me = strmid(me, 0, strpos(me,' <')) me = strlowcase(me) END ELSE: BEGIN me = calls[1] ; Calling procedure name and file name me = strmid(me, strpos(me,'<')+1) me = strmid(me, 0, strpos(me,'(')) IF n_elements(env) NE 0 THEN BEGIN val = getenv(env) IF val NE '' AND strpos(me,val) EQ 0 THEN me = filepath(root='$'+env,strmid(me, strlen(val)+1)) ENDIF IF directory THEN me = GetFileSpec(me, upto='directory') END ENDCASE RETURN, me & END