How to set environment variables in IDLDE
From
Luke@21:1/5 to
All on Wed Nov 29 10:28:07 2017
I know this is a really old thread, but since this is where I landed in my great search on this issue.. in 2017.. I figured I'd post my solution since I cannot seem to make anything else work. This is code you can put in your startup.pro file, and it
assumes you declare your environmental vars with the export command in your .bash_profile. Change the relevant lines as needed. Works like a charm for me.. after all these years of declaring pathnames explicitly for all my scripts run in my IDLDE
environment.
;Set user environmental variables
file = getenv('HOME')+path_sep()+'.bash_profile'
line = ''
openr, lun, file, /get_lun
while not eof(lun) do begin & $
readf, lun, line & $
if strcmp(line, 'export ', 7, /fold_case) then begin & $
temp = strsplit(strmid(line, 7), '=', /extract) & $
env = strsplit(temp[1], path_sep(), /extract, count=n) & $
for ienv=0, n-1 do $
if strcmp(env[ienv], '$', 1) then $
env[ienv] = getenv(strmid(env[ienv],1)) & $
if product(strlen(env) gt 0) then $
setenv, temp[0]+'='+strjoin(env, path_sep()) & $
endif & $
endwhile
free_lun, lun
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)