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

Home » Public Forums » archive » Unsatisfactory 'file_test()' behavior
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Unsatisfactory 'file_test()' behavior [message #28435] Mon, 17 December 2001 06:43 Go to next message
mfein is currently offline  mfein
Messages: 2
Registered: November 2001
Junior Member
Hi all--

If I do

e = file_test('')

that is, test for the existence of a file whose name is a zero-length
string, I get e = 1. This is not good ! (Using IDL v5.4 WinNT 4.0).


Matt Feinstein does not include his email address
in the text of usenet postings.
--------
Harvard Law of Automotive Repair: Anything that goes away
by itself will come back by itself.
Re: Unsatisfactory 'file_test()' behavior [message #28585 is a reply to message #28435] Thu, 20 December 2001 10:43 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Matt Feinstein wrote:
> If I do
>
> e = file_test('')
>
> that is, test for the existence of a file whose name is a zero-length
> string, I get e = 1. This is not good ! (Using IDL v5.4 WinNT 4.0).

How about this:

FUNCTION FILETEST, FILE, VERBOSE=VERBOSE

;- Returns true (1B) if the named file can be
;- opened for reading, and false (0B) otherwise

;- Try opening the file for reading
openr, lun, file, /get_lun, error=error

;- Check error status
if (error eq 0) then begin
result = 1B
free_lun, lun
endif else begin
result = 0B
if keyword_set(verbose) then $
message, !err_string, /continue
endelse

;- Return result
return, result

END

IDL> help, filetest('')
<Expression> BYTE = 0
IDL> help, filetest('', /verbose)
% FILETEST: OPENR: Null filename not allowed.
<Expression> BYTE = 0

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: image cutting,
Next Topic: Memory management by 5.4 on Sunblade

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

Current Time: Wed Oct 08 18:41:49 PDT 2025

Total time taken to generate the page: 0.00452 seconds