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

Last change on this file since 371 was 371, checked in by pinsard, 16 years ago

improvements of headers (alignments of IDL prompt in examples)

  • 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;-
37FUNCTION protype, file
38;
39  compile_opt idl2, strictarrsubs
40;
41  filepro = find(file[0], /onlypro, /firstfound)
42  if filepro EQ 'NOT FOUND' then return, -1
43  name = file_basename(filepro, '.pro')
44;
45  allines = getfile(filepro)
46  CASE 1 OF
47; this is a procedure
48    max(stregex(allines, '^ *pro ?' + name, /fold_case, /boolean)):RETURN, 'proc'
49; this is a function
50    max(stregex(allines, '^ *function ?' + name, /fold_case, /boolean)):RETURN, 'func'
51; this is an IDL batch file
52    ELSE:RETURN, 'batch'
53  ENDCASE
54
55  RETURN, -1
56END
Note: See TracBrowser for help on using the repository browser.