source: trunk/SRC/Utilities/protype.pro @ 128

Last change on this file since 128 was 128, checked in by pinsard, 18 years ago

improvements of Utilities/*.pro header

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; @file_comments
6; test is a ".pro" file corresponds to an IDL procedure, function or batch file.
7;
8; @categories utilities
9;
10; @param file {in} A scalar of string type, the name of the ".pro" file to be tested
11;    if necessary, the input name is completed with '.pro'
12;     and its path found in !path
13;
14; @returns A scalar of string type: 'proc', 'func' or 'batch'
15;
16; @examples
17;
18; IDL> print, protype('protype')
19;      func
20; IDL> print, protype('protype.pro')
21;      func
22; IDL> print, protype('init')
23;      batch
24; IDL> print, protype('plt')
25;      proc
26;
27; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
28;                       Feb 2006
29;
30; @version $Id$
31;-
32;------------------------------------------------------------
33;------------------------------------------------------------
34;------------------------------------------------------------
35FUNCTION protype, file
36;
37;
38  compile_opt idl2, strictarrsubs
39;
40  filepro = (find(file[0], /onlypro, /firstfound))[0]
41  if filepro EQ 'NOT FOUND' then return, -1
42  name = file_basename(filepro, '.pro')
43;
44  allines = getfile(filepro)
45  CASE 1 OF
46; this is a procedure
47    max(stregex(allines, '^ *pro ?' + name, /fold_case, /boolean)):RETURN, 'proc'
48; this is a function
49    max(stregex(allines, '^ *function ?' + name, /fold_case, /boolean)):RETURN, 'func'
50; this is an IDL batch file
51    ELSE:RETURN, 'batch'
52  ENDCASE
53 
54  RETURN, -1
55END
Note: See TracBrowser for help on using the repository browser.