comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to set the default working directory?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: How to set the default working directory? [message #66028] Tue, 14 April 2009 05:52
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rainingpeace@gmail.com writes:

> I am trying to use IDL to read and write CDF files. Now I am suffering
> a problem. I am trying to set my default working directory to "D:
> \IDLWorkspace\". And I set "Reference->IDL->Path" and add the "D:
> \IDLWorkspace" to the list and move it to the top. But it does not
> work.
> The reason why I want to set this directory is that otherwise every
> time I am trying to read a file, I have to write the full path. By
> setting a default working directory, I can just use
> id=cdf_open('ge_edb3sec_mgf_20000125_v01.cdf')
> instead of
> id=cdf_open('C:\ge_edb3sec_mgf_20000125_v01.cdf'). I believe such a
> small aim is achievable in such a powerful software like IDL. It is
> just that I do not know how to do that.
> This is just a simple example. My directory is much longer.
> So as mentioned, I failed at setting the working directory. I hope
> some one could help me.

You can always change your working directory with the
CD command:

IDL> CD, 'D:\IDLWorkspace\'

On Windows, I usually prefer to do this with XCD, which allows
me to point and click to move to directories. You can find
XCD here:

http://www.dfanning.com/programs/xcd.zip

But, most of the time, I prefer NOT to change directories,
but to let the directories come to me. If your data file is
in a directory in your IDL path, and there is a *.pro in that
directory, then I find the program Find_Resource_File more
intuitive and less a bother than FILE_SEARCH:

IDL> datafile = Find_Resource_File('ge_edb3sec_mgf_20000125_v01.cdf')

This program was originally designed to find resource files
like the Brewer color table file, but, as I say, it has become
more useful than that to me. You can find it among the other
Coyote Library files:

http://www.dfanning.com/documents/programs.html

Another thing I sometimes do, especially if I am always switching
from LINUX to Windows machines, is define default data directories
in my IDL startup file:

CatSetDefault, 'CDF_DATA_DIR', 'D:\Workspace\'

Then, in my programs, I get the name of the file I want like
this:

datafile = Filepath(ROOT_DIR=CatGetDefault('CDF_DATA_DIR'), $
'ge_edb3sec_mgf_20000125_v01.cdf')

The CatSetDefault and CatGetDefault programs are utility programs
in the Catalyst Library code.

http://www.dfanning.com/catalyst/howtoinstall.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: How to set the default working directory? [message #66030 is a reply to message #66028] Tue, 14 April 2009 05:43 Go to previous message
David Gell is currently offline  David Gell
Messages: 29
Registered: January 2009
Junior Member
On Apr 14, 12:08 am, rainingpe...@gmail.com wrote:
> Hi all,
>
> I am trying to use IDL to read and write CDF files. Now I am suffering
> a problem. I am trying to set my default working directory to "D:
> \IDLWorkspace\". And I set "Reference->IDL->Path" and add the "D:
> \IDLWorkspace" to the list and move it to the top. But it does not
> work.
> The reason why I want to set this directory is that otherwise every
> time I am trying to read a file, I have to write the full path. By
> setting a default working directory, I can just use
> id=cdf_open('ge_edb3sec_mgf_20000125_v01.cdf')
> instead of
> id=cdf_open('C:\ge_edb3sec_mgf_20000125_v01.cdf'). I believe such a
> small aim is achievable in such a powerful software like IDL. It is
> just that I do not know how to do that.
> This is just a simple example. My directory is much longer.
> So as mentioned, I failed at setting the working directory. I hope
> some one could help me.
> Thanks in advance.
>
> Sincerely,
> Li, Tongmu

The !path and path preference are only used in finding the files
containing IDL functions and procedures. It doesn't have any effect on
searches for other types of files. You can use the CD procedure to set
the current working directory. A more general solution, that limits
typing, is to use the DIALOG_PICKFILE function to display a file
chooser. You can use this function to select a file, then save the
directory path for the default in future calls.
Re: How to set the default working directory? [message #66034 is a reply to message #66030] Tue, 14 April 2009 02:51 Go to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Apr 14, 7:08 am, rainingpe...@gmail.com wrote:
> The reason why I want to set this directory is that otherwise every
> time I am trying to read a file, I have to write the full path. By
> setting a default working directory, I can just use
> id=cdf_open('ge_edb3sec_mgf_20000125_v01.cdf')
> instead of
> id=cdf_open('C:\ge_edb3sec_mgf_20000125_v01.cdf'). I believe such a
> small aim is achievable in such a powerful software like IDL. It is
> just that I do not know how to do that.

Search for CD in the online IDL manual.

Maarten
Re: How to set the default working directory? [message #66035 is a reply to message #66034] Tue, 14 April 2009 02:50 Go to previous message
russell.grew is currently offline  russell.grew
Messages: 74
Registered: February 2005
Member
Assuming you're on Windows and using 6.x,

File --> Preferences --> Startup --> Working directory

I would hope IDL 7.x is similar.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: getting derivatives from spline
Next Topic: Re: no focus on a widget

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:34:28 PDT 2025

Total time taken to generate the page: 0.00646 seconds