Re: File test [message #4430] |
Wed, 31 May 1995 00:00  |
knipp
Messages: 68 Registered: January 1993
|
Member |
|
|
In article acg@post.gsfc.nasa.gov, thompson@orpheus.nascom.nasa.gov (William Thompson) writes:
... (deleted)
>
> Actually, that's why I use. I find it extremely fast, much faster than the IDL
^
CORRECT ----------------------------------------------|
> built-in function called FINDFILE. I would, however, suggest modifying your
> routine to read
>
> FUNCTION fexists, file
> ON_IOERROR, error
> openr,unit,file
> free_lun,unit
> ; found the file
> return, 1
>
> error:
> ;can't open the file, so it's probably not there
> return,0
> end
>
> So that you don't run into a problem if unit 1 is already used elsewhere.
>
> Bill Thompson
I have a function EXIST_F (to check the existence of a file) using FINDFILE,
- and just yesterday I suggested to use FINDFILE for this.
Now , thanks to Bill Thompson, I realize that OPENR is much, much faster
- and find a function (I wrote some time ago) EXIST_D, which checks the
existence of a directory, ...
AND IT USES OPENR to perform that check.
So, next time be careful with my suggestions, ;-)
I must be out of my brain sometimes.
(A small difference to the above stated solution:
openr, unit, file, /get_lun, ERROR=ERROR
if ERROR ne 0 then return, 0
free_lun, unit
return, 1
)
By the way, the function EXIST_F now utilizes OPENR,... ;-)
Thanks again Bill
Karl
------------------------------------------------------------ ------------
Karlheinz Knipp
knipp@ipi.uni-hannover.de
------------------------------------------------------------ ------------
|
|
|