It actually depends on the version of IDL you are using. If you are using an IDL version between 6.2 and 7.0.3, then you use PREF_SET
to control the paths. Prior to 6.2 you can set environment variables in Ubuntu and modify the IDL setup bash file (should come with IDL). After v7.0.3, you can explicitly set the value for !PATH
as a string.
You will want to know what the search path separator is for your OS. If you are using IDL v5.5 or greater, then you can define:
sepath_sep = PATH_SEP(/SEARCH_PATH)
which is probably going to be :
for Linux (it is for Unix at least). You will also want to know your current working directory, which can be defined in the following way:
vern = !VERSION.RELEASE ;; e.g., '7.1.1'
test = (vern[0] GE '6.0')
IF (test[0]) THEN cwd_char = FILE_DIRNAME('',/MARK_DIRECTORY) ELSE cwd_char = '.'+slash[0]
cur_wdir = FILE_EXPAND_PATH(cwd_char[0])
;; Check for a trailing slash and add it if need be...
To then find all the subdirectories within your current working directory, you can do the following:
t_path0 = EXPAND_PATH('+'+cur_wdir[0],/ARRAY)
t_path = STRJOIN(t_path0,sepath_sep[0],/SINGLE)
Generally, I do more than one thing to ensure that IDL can find my files. I set an environment variable and I specify the !PATH
system variable (I have v7.1.1). You can do this in IDL in the following way:
;; First define the location of the IDL libraries
def_idldir = !DIR ;; e.g., '/Applications/itt/idl71'
test = (GETENV('IDL_DIR') EQ '')
IF (test) THEN env_idldir = def_idldir[0] ELSE env_idldir = GETENV('IDL_DIR')
;; Again, check for trailing slash here and add if absent
IF (test) THEN SETENV,'IDL_DIR='+env_idldir[0]
;; First check whether an initial path exists
;; --> If not, set one
idlpath = GETENV('IDL_PATH')
test_idl = (idlpath[0] EQ '')
IF (test_idl) THEN new_path = t_path[0] ELSE new_path = t_path[0]+sepath_sep[0]+idlpath[0]
IF (test_idl) THEN SETENV,'IDL_PATH='+new_path[0]
;; Test to see if after version 7.0.3 and/or after version 6.2
test__62 = (vern[0] GE '6.2') AND (vern[0] LT '7.0.3')
test_703 = (vern[0] GE '7.0.3')
IF (test__62) THEN PREF_SET,'IDL_PATH',new_path[0],/COMMIT
IF (test_703) THEN !PATH = EXPAND_PATH(new_path[0])
This should give you the correct path specifications.