Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
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
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/