;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:isafile ; ; PURPOSE:find a file and check if it is a real file! ; ; CATEGORY:for open ; ; CALLING SEQUENCE:filename = isafile() ; ; INPUTS:none ; ; KEYWORD PARAMETERS: ; FILENAME: a proposed filename. ; IODIRECTORY: a directory where must be the file. ; /NEW:to specify that filename is a new file ; ; OUTPUTS:the filename ; ; COMMON BLOCKS:none ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) ; 11/2/2000 ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ FUNCTION isafile, FILENAME = filename, IODIRECTORY = iodirectory, FILTER = filter, NEW = new ;------------------------------------------------------------ ; we find the filename. ;------------------------------------------------------------ ; is filename given by the FILENAME keyword a good one? ; si iodirectory n''est pas definit on l''initialise au repertoire courant if NOT keyword_set(filename) then filename = 'nimportequoi' thisOS = strupcase(strmid(!version.os_family, 0, 3)) CASE thisOS OF 'MAC':sep = ':' 'WIN':sep = '\' ELSE:sep = '/' ENDCASE ; we complete filename by iodirectory? if strpos(filename, sep) EQ -1 then begin if NOT keyword_set(iodirectory) then cd, current = iodirectory ; si iodirectory ne finit pas par sep on le rajoute if rstrpos(iodirectory, sep) NE strlen(iodirectory)-1 then $ iodirectory = iodirectory+sep filename = iodirectory+filename ENDIF if keyword_set(new) then return, filename test = findfile(filename) ; le nom cherche correspond bien a un fichier? while test[0] EQ '' OR n_elements(test) GT 1 do BEGIN ; on en cherche un tant qu''il ne correspond a rien! test = test[0] if keyword_set(filter) AND thisOS NE 'MAC' AND thisOS NE 'WIN' then $ filename = dialog_pickfile(path = iodirectory, filter = filter) $ ELSE filename = dialog_pickfile(path = iodirectory) if filename EQ '' then return, report('read_data canceled') test = findfile(filename) endwhile return, filename end