;+ ; NAME: ; env_slashes ; PURPOSE: ; Fixes environment variables on Windows ; CATEGORY: ; gen/idl/environment ; CALLING SEQUENCE: PRO env_slashes ; INPUTS: ; (from Windows by retrieving results of spawning ; the DOS 'set' command). ; OUTPUTS: ; (modified env variables) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; txt_read ; PROCEDURE: ; On Windows SSW sets up environment variables with a mix ; of back- and forward slashes. This causes problems for e.g. ; the IDL dialog_pickfile procedure. ; This procedure runs through all env variables and changes ; forward slashes to backward slashes. Only env variables of ; the form SSW_*_INSTR are not modified. ; MODIFICATION HISTORY: ; FEB-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- if !version.os_family ne 'Windows' then $ return ; Only on Windows case !version.release lt 5.4 of 0: spawn, 'set', env ; Works on IDL V >= 5.4 1: begin tmp = filepath(root=getenv('IDL_TMPDIR'),'tmp.'+string(fix(10000*randomu(s)),format='(I5.5)')) spawn, 'set > '+tmp i = txt_read(tmp, env, /delete) end endcase for i=0,n_elements(env)-1 do begin env[i] = strmid(env[i],0,strpos(env[i],'=')) ; Extract name (preceding equal sign) envdef = getenv(env[i]) ; Translate env variable ; Don't touch env variables SSW_*_INSTR if (strpos(env[i],'SSW_') ne 0 or strpos(env[i],'_INSTR') eq -1) and $ strpos(envdef, '/') ne -1 then begin ; If forward slash present setenv, env[i]+'='+strjoin( strtok(envdef, '/', /extract ), '\') ; .. fix it. message, /info, env[i]+'='+envdef+' --> '+getenv(env[i]) endif endfor return & end