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

Home » Public Forums » archive » Re: file paths
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 paths [message #8559] Thu, 03 April 1997 00:00 Go to previous message
Phil Williams is currently offline  Phil Williams
Messages: 78
Registered: April 1996
Member
David wrote:
>
> hi,
>
> I want to add some code at the top of a fairly large project that will
> tell IDL where to look for all the subroutines it'll need. They are in
> various different folders, organized by their function. I want the code
> to compile everything automatically, even if I move the source around.
> (It would be messy to put all the subroutines in the same folder).
>
> Is there any way other than help, /source to show the path of the
> currently executing file? If I knew the path to the executing file, I
> could append it (with a +) to !path to make this work, right?
>
> Thanks in advance for any help!
>
> cheers!
> dave

You could search a given directory, and any subdirs off that one for the
file, get the path once, and if found, and then append that to the !path
var. "Boy," you say, "that's a lot of work Phil." Yes, but I already
have a routine that does just that!

Check out <http://www.irc.chmcc.org/idl/philsIDL.html> and take a look
at fileExists.pro. You'll also need direxists.pro (which is a hack of
some of David Fanning's code). Here's the header:

function fileExists, file, path, $
FOLLOW_DIR = FOLLOW_DIR, $
GET_PATH = GET_PATH
;+
; NAME: FILEEXISTS.PRO
;
; PURPOSE: Determines the existence of a file.
;
; CATEGORY: File I/O
;
; CALLING SEQUENCE: result = fileExists(file[, path, /follow_dir,
/get_path])
;
; INPUTS:
; file : a string containing the file name
;
; OPTIONAL INPUTS:
; path : The given path to search. If not given then searching
; begins at the current directory
;
; KEYWORD PARAMETERS:
; FOLLOW_DIR : If set then subdirectories are recursively searched.
; GET_PATH : If set and file exists then the path to the file is
; returned.
; OUTPUTS:
; If GET_PATH is specified and the search was successful then the
; path to the file is returned. Otherwise 1 is returned if the file
; exists and 0 if the file does not.
;
; OPTIONAL OUTPUTS: none
;
; COMMON BLOCKS: none.
;
; SIDE EFFECTS: none.
;
; RESTRICTIONS: none.
;
; PROCEDURE:
; IDL> t = fileExists('file.pro',/follow,/get)
;
; MODIFICATION HISTORY:
; 13 Dec 96 Initial Coding. PMW
; 29 Dec 96 Added FOLLOW_DIR keyword for recursive searches
; 30 Dec 96 Added GET_PATH keyword to return path if file is found.
;-

Just a suggestion. Hope this is what you had in mind.

Phil

--
/*********************************************************** ********/
Phil Williams, Ph.D.
Research Instructor
Children's Hospital Medical Center "One man gathers what
Imaging Research Center another man spills..."
3333 Burnet Ave. -The Grateful Dead
Cincinnati, OH 45229
email: williams@irc.chmcc.org
URL: http://scuttle.chmcc.org/~williams/
/*********************************************************** ********/
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Is that window open??
Next Topic: Re: Is that window open??

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

Current Time: Wed Oct 08 15:53:36 PDT 2025

Total time taken to generate the page: 0.00393 seconds