;+ ; NAME: ; isfile ; PURPOSE: ; Check if a file exists ; DESCRIPTION: ; CATEGORY: ; fileio ; CALLING SEQUENCE: ; exists = IsFile(fn) ; INPUTS: ; fn: the filename ; OPTIONAL INPUT PARAMETERS: ; KEYWORD INPUT PARAMETERS: ; OUTPUTS: ; exists (boolean): true if file exists ; KEYWORD OUTPUT PARAMETERS: ; COMMON BLOCKS: ; SIDE EFFECTS: ; RESTRICTIONS: ; PROCEDURE: ; call findfile ; MODIFICATION HISTORY: ; 2002/05/30 - Initial version written, Leslie Young SwRI ;- function isfile, fn if n_elements(fn) eq 1 then begin res = findfile(fn, count = count) return, (count gt 0) and (fn ne '') endif else begin n = n_elements(fn) out = (fn ne '') ; to get the right size and protect against '' for i = 0, n-1 do out[i] = isfile(fn[i]) and out[i] return, out endelse end pro isfileTEST fn = 'isfile.pro' print, fn, IsFile(fn) fn = 'NoSuchFile' print, fn, IsFile(fn) end