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

Last change on this file since 224 was 224, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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