FUNCTION unhide_env, hidden_spec, directory=directory, silent=silent ;+ ; NAME: ; unhide_env ; PURPOSE: ; ; CATEGORY: ; gen/idl/toolbox ; CALLING SEQUENCE: ; spec = unhide_env(env_spec [,/directory] ; INPUTS: ; hidden_spec scalar; type: string ; file or directory specification ; Usually starts with a $-sign ; OPTIONAL INPUTS: ; /directory if set and hidden_spec='', then the ; current directory is used ; OUTPUTS: ; spec scalar; type: string ; hidden_spec with the env var translated. ; If something goes wrong (the env var ; doesn't exist or points to a non-existent ; directory, then spec = '' is returned ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, CheckDir ; PROCEDURE: ; MODIFICATION HISTORY: ; JUL-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, hidden_spec, '', set=spec InitVar, directory , /key InitVar, silent , /key IF directory AND spec EQ '' THEN cd, current=spec spec = strtrim(spec,2) IF strmid(spec,0,1) EQ '$' THEN BEGIN slash = strpos(spec,os_separator(/dir)) CASE slash EQ -1 OF 0: slash = slash-1 1: slash = strlen(spec)-1 ENDCASE root = getenv( strmid(spec,1,slash) ) CASE root EQ '' OF 0: BEGIN IF slash LT strlen(spec)-1 THEN slash = slash+1 spec = filepath(root=root, strmid(spec,slash+1) ) END 1: spec = '' ENDCASE ENDIF IF spec NE '' AND directory THEN $ IF NOT CheckDir(GetFileSpec(spec,upto='directory'),silent=silent) THEN $ spec = '' RETURN, spec & END