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

Last change on this file since 285 was 285, checked in by smasson, 17 years ago

allways return back a scalar is /firstfound used

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