pro getdir, filename, dirname, dirsep ;+ ; NAME: ; getdir ; PURPOSE: (one line) ; find the directory that filename is in ; DESCRIPTION: ; ; CATEGORY: ; Miscellaneous ; CALLING SEQUENCE: ; getdir, filename, dirname, dirsep ; INPUTS: ; filename ; OPTIONAL INPUT PARAMETERS: ; none ; ; KEYWORD INPUT PARAMETERS: ; none ; KEYWORD OUTPUT PARAMETERS: ; none ; OUTPUTS: ; dirname - the directory that filename.pro is in ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; Defines the system variable !eph using defsysv ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ; Written 2005 January 15, by Cathy Olkin, SwRI ;- name=filename os = !VERSION.OS name = 'naifinit' IF os EQ 'MacOS' then message, $ 'This procedure not available for the Macintosh -- use the the FINDER menu' ;Set up separate copy commands for VMS and Unix case !VERSION.OS_FAMILY OF 'vms': begin dirsep = '' name = strupcase(name) end 'Windows':dirsep = '\' else: dirsep = '/' ENDCASE path_dir = expand_path(!PATH,/ARRAY, Count = N_dir) ; Loop over each directory in !PATH until procedure name found for idir = 0, N_dir-1 do begin dir = path_dir[idir] a = findfile(dir + dirsep + name +'.pro',COUNT=i) if I GE 1 then dirname = dir ;Found by FINDFILE endfor end