★ Path management
posted Tue 1 Apr 2008 by Michael Galloy under IDLThere are mechanisms in the IDL Workbench (or the old IDLDE) to set the IDL !PATH
, but I have not found them useful. I have a somewhat byzantine system to set my path, but it works well for me. Since there has been discussion on the newsgroup recently about problems others are having, I thought I would write up my method.
My requirements for setting the path:
- I need to be able to control exactly what appeared in my path. It needs to be clear what is currently in the path and easy to change what will be in the path the next time I start IDL. I don’t need to be able to change my path while using IDL (though I think my solution could be used for that too).
- Directories with subdirectories containing code (i.e. using
+
) should still appear as a single entry. - Needs to work for both the command line and the Workbench.
The system consists of three parts: a text file with directories, a startup file that looks at the text file, and a handy library routine that sets the path.
First, the text file specifying the path contains one directory per line. Here’s mine that I keep in my home directory. Lines starting with a +
include subdirectories; lines beginning with a ;
are ignored.
Next, I included a few lines in my startup file to read the text file. Here’s my startup file. If you set your startup file using PREF_SET
it will be set for both the command line and the Workbench (I think this is true if you set it within the Workbench as well).
Finally, the startup file uses MG_SET_PATH
(code, docs).
It may be complicated to setup, but it’s straightforward to change the path once setup and it hasn’t surprised me yet.
March 11th, 2009 at 4:40 am
Thanks for that great idea, I think this can simplify Path management considerably.
My stupid question now: where do I put the definition of mg_set_path? (After all, I have not defined any paths yet…)
Best,
Daniel
March 11th, 2009 at 8:35 am
Yes, you have to “bootstrap” the system: 1) set the IDL_STARTUP preference, 2) exit IDL, 3) change directories to where MG_SET_PATH is located, 4) start IDL. This works fine on the command line, but on Windows you are going to have to manually compile and run things the first time.