IDL startup trick [message #3728] |
Tue, 28 February 1995 20:54 |
rsmith
Messages: 7 Registered: February 1995
|
Junior Member |
|
|
I just got this to work, and thought I'd toss it out for everyone's
consideration and/or improvements. It's fairly general, although as I
think about it does require a certain type of file organization.
The problem is that I use IDL for a number of different tasks (I'm a
graduate student in astrophysics, working in the general area of
X-rays from supernovae.) So, I have an "xray" working directory, a
"hydro" directory, "dust" and so on. Each has a subdirectory named
idl, where I store any idl code I've written to work on the project,
and in that directory, a "start.pro" batch file to compile code, setup
common blocks, and so on.
The problem is that I could be anywhere in a given directory structure
when I start idl, and want the start.pro for that directory to be
executed, setting me up to work. Searching through the IDL manual, I
find out that:
setenv IDL_STARTUP "~/idl/global_startup.pro"
will set things up so that idl will run the "global_startup.pro"
routine anytime I start up.
Then, I write the following batch file, global_startup.pro:
;-----------------global_startup.pro------------------------ ---
; Get current directory
cd,current = cdir
idir = ''
; Figure out what directory structure we're in.
check = 'hydro'
result = strpos(cdir,check)
if (result ne -1) then idir=strmid(cdir,0,result+strlen(check))
check = 'xray'
result = strpos(cdir,check)
if (result ne -1) then idir=strmid(cdir,0,result+strlen(check))
check = 'cooling/dust'
result = strpos(cdir,check)
if (result ne -1) then idir=strmid(cdir,0,result+strlen(check))
; Set the path to the correct idl directory
if (idir ne '') then !path = !path + ':'+idir+'/idl'
; Add main idl directory to path as well.
!path = !path + ':~/idl'
; Remove extraneous variables
delvar,cdir,idir,result
; Execute the start.pro procedure, now in the path.
@start
;-----------------global_startup.pro------------------------ ---
This seems to work exactly as planned, and now anytime I'm in a
directory with the word "hydro" in it, my hydro start.pro is executed,
and so on. If I'm not in any pre-defined directory, the default
start.pro in the ~/idl directory is run.
Hope it's useful to someone out there!
Randall Smith
rsmith@wisp5.physics.wisc.edu
|
|
|