[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filename check



"Stuart Colley" <src@star.ucl.ac.uk> wrote...
>
> Can anyone suggest a way to check that a file exists before attempting to
> read from it, since the error messages obtained from trying to read from a
> non-existing file, don't make it clear that file doesn't exist.

Of course, the solutions in all the other replies point to why this was
needed, and now appears in IDL 5.4:

IDL> Print, File_Test('image.gif')
           0
IDL> Print, File_Test('image.tif')
           1

File_Test has many fancy keywords for "what kind of file do you expect to
find?", etc.:

[, /DIRECTORY | ,  /EXECUTABLE | , /READ | , /REGULAR | ,  /WRITE | ,
/ZERO_LENGTH] [, GET_MODE=variable]

Cheers,
--
-Dick

Dick Jackson                     /         dick@d-jackson.com
D-Jackson Software Consulting   /    http://www.d-jackson.com
Calgary, Alberta, Canada       /   Voice/Fax: +1-403-242-7398