;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME: protype ; ; PURPOSE: test is a ".pro" file corresponds to an IDL procedure, ; function or batch file. ; ; CATEGORY: ; ; CALLING SEQUENCE: type = protype(profilename) ; ; INPUTS: A scalar of string type, the name of the ".pro" file to be tested ; if necessary, the input name is completed with '.pro' ; and its path found in !path ; ; KEYWORD PARAMETERS: NONE ; ; OUTPUTS: A scalar of string type: 'proc', 'func' or 'batch' ; ; COMMON BLOCKS: none ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; IDL> print, protype('protype') ; func ; IDL> print, protype('protype.pro') ; func ; IDL> print, protype('init') ; batch ; IDL> print, protype('plt') ; proc ; ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) ; Feb 2006 ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ FUNCTION protype, file ; filepro = (find(file[0], /onlypro, /firstfound))[0] 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