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

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • 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}
12; A scalar of string type, 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; A scalar of string type: 'proc', 'func' or 'batch'
18;
19; @examples
20;
21; IDL> print, protype('protype')
22;      func
23; IDL> print, protype('protype.pro')
24;      func
25; IDL> print, protype('init')
26;      batch
27; IDL> print, protype('plt')
28;      proc
29;
30; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
31;                       Feb 2006
32;
33; @version $Id$
34;-
35;------------------------------------------------------------
36;------------------------------------------------------------
37;------------------------------------------------------------
38FUNCTION protype, file
39;
40;
41  compile_opt idl2, strictarrsubs
42;
43  filepro = (find(file[0], /onlypro, /firstfound))[0]
44  if filepro EQ 'NOT FOUND' then return, -1
45  name = file_basename(filepro, '.pro')
46;
47  allines = getfile(filepro)
48  CASE 1 OF
49; this is a procedure
50    max(stregex(allines, '^ *pro ?' + name, /fold_case, /boolean)):RETURN, 'proc'
51; this is a function
52    max(stregex(allines, '^ *function ?' + name, /fold_case, /boolean)):RETURN, 'func'
53; this is an IDL batch file
54    ELSE:RETURN, 'batch'
55  ENDCASE
56 
57  RETURN, -1
58END
Note: See TracBrowser for help on using the repository browser.