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

Home » Public Forums » archive » File_Which What!?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: File_Which What!? [message #33053 is a reply to message #32990] Mon, 25 November 2002 14:00 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 22 Nov 2002 07:41:22 -0700, Jaco van Gorkom wrote:

> "David Fanning" <david@dfanning.com> wrote in message
> news:MPG.184759add416747d989a42@news.frii.com...
>> Mark Hadfield (m.hadfield@niwa.co.nz) writes:
>>
>>> This would be sensible, *if* FILE_WHICH was to be used only to search
>>> for .pro or .sav files. There is nothing in the documentation that
>>> says this is the case, and I (and David) have used it to search for
>>> files with other extensions. I'm just glad it was David who got
>>> tripped up by the hidden gotcha. (Not that I'm not sympathetic,
>>> David, but...)
>>
>> Well, maybe there should be an EVERYDARNONE keyword, to force it to
>> search everything. Now that I think about it, why would you have files
>> on your path that you didn't want to search? Maybe I'll revisit this
>> with my source. :-)
>
> Why are you using FILE_WHICH to *search* for files in the first place?
> FILE_SEARCH (or FINDFILE) would seem a better candidate. Anyway,
> FILE_WHICH should tell you exactly *which* file IDL would find, if it
> should ever go looking for a fire.clt file on its path. Directories
> without .pro or .sav files (at IDL startup time!!) simply are not
> included in the IDL path, states the Help for !PATH.
>
> sympathetically yours,
> Jaco
>
> PS: As I started using IDL, I frequently ran into problems that I could
> only solve by exiting and restarting IDL. Later I discovered many of the
> reasons, and this was one of them.

FILE_WHICH simply scrubs through a list of paths and looks for the
first existing file specified in one of them. This is fine if you
know which file you're looking for. And FINDFILE (with FILEPATH) lets
you find any number of files by pattern (like '*.clt'), assuming you
know the directory(ies) they are in.

But what to do if you don't know where they are, but you need all
'.clt' files from some special directory? My solution has been to
place alongside the target files a special marker routine
(e.g. irs_calib_dir_marker.pro). This dummy routine is compiled, and
ROUTINE_INFO is used to get its source, from which the path is derived
and placed in a common block. Ugly, but pretty failsafe. It also
ensures you're getting exactly the files you meant to. I bundle it
all up into an include file, which I "@" at the top of any routine
which needs the directory. It looks like:


common irs_dir, irs_calib_dir
if n_elements(irs_calib_dir) eq 0 then begin
irs_calib_dir_marker
source=(routine_info('irs_calib_dir_marker',/SOURCE)).PATH
dir=strmid(source,0,strpos(source,path_sep(),/REVERSE_SEARCH ))
if NOT file_test(dir,/DIRECTORY) then $
message,'Cannot locate IRS calibration data directory: '+dir
irs_calib_dir=dir
endif
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Structure Pass By Reference?
Next Topic: Re: sec : U Re: De-sensitizing individual list elements

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

Current Time: Fri Nov 28 17:02:17 PST 2025

Total time taken to generate the page: 0.24227 seconds