Re: file_expand_path [message #51858 is a reply to message #35617] |
Thu, 14 December 2006 18:17   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
damonanomad@gmail.com writes:
> I guess that the short answer is that the file_expand_path function
> will not do what I had hoped (give the path of a file in some "unknown"
> sub-directory of my working directory). In looking at the online help
> index some, I think that file_search may be more suited to what I am
> trying to do. However, when I try to use it following one of their
> examples (#6):
>
> Result = FILE_SEARCH('$HOME', '*', /EXPAND_ENVIRONMENT,
> /TEST_DIRECTORY)
>
> Result has nothing in it although there are sub-directories and
> sub-sub-directories in my working directory. Is '$HOME' not the
> working directory in windows?
Yeah, I'm not sure what they are thinking with that
example. $HOME is not a standard Windows environment
variable. Perhaps they mean "this is how you would do
it IF you had defined an environment variable named
$HOME." Hard to say.
I think in general you have to know where you are
when you create a file path. If you are sure the
file is located in a known subdirectory (say IMAGES)
of where you are currently located, you might create
a path to an image file like this:
CD, Current=thisDir
filename = Filepath(Root_Dir=thisDir, SubDir='images', 'test.img')
Programs exist that help with this. PROGRAMROOTDIR, for example:
http://www.dfanning.com/programs/programrootdir.pro
Or, you could create your own IDL system variable:
IDL> DefSysVar, '!HOME', 'C:\RSI\COYOTE\TEST'
IDL> filename = Filepath(Root_Dir=!HOME, SubDir='images', 'test.img')
Anyway, a few ideas.
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.")
|
|
|