;+ ; ; @file_comments ; test is a ".pro" file corresponds to an IDL procedure, function or batch file. ; ; @categories ; Utilities ; ; @param FILE {in}{required}{type=string} ; the name of the ".pro" file to be tested. ; if necessary, the input name is completed with '.pro' ; and its path found in !path ; ; @returns ; -1 if not found ; A scalar of string type: 'proc', 'func' or 'batch' ; ; @examples ; ; IDL> print, protype('protype') ; func ; IDL> print, protype('protype.pro') ; func ; IDL> print, protype('init') ; batch ; IDL> print, protype('plt') ; proc ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; Feb 2006 ; ; @version ; $Id$ ; ;- FUNCTION protype, file ; compile_opt idl2, strictarrsubs ; filepro = find(file[0], /onlypro, /firstfound) if filepro EQ 'NOT FOUND' then return, -1 name = file_basename(filepro, '.pro') ; allines = getfile(filepro) CASE 1 OF ; this is a procedure max(stregex(allines, '^ *pro ?' + name, /fold_case, /boolean)):RETURN, 'proc' ; this is a function max(stregex(allines, '^ *function ?' + name, /fold_case, /boolean)):RETURN, 'func' ; this is an IDL batch file ELSE:RETURN, 'batch' ENDCASE RETURN, -1 END