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
RevLine 
[69]1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
[128]5; @file_comments
6; test is a ".pro" file corresponds to an IDL procedure, function or batch file.
[69]7;
[93]8; @categories utilities
[69]9;
[93]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'
[69]12;     and its path found in !path
13;
[93]14; @returns A scalar of string type: 'proc', 'func' or 'batch'
[69]15;
[128]16; @examples
[69]17;
[128]18; IDL> print, protype('protype')
[69]19;      func
[128]20; IDL> print, protype('protype.pro')
[69]21;      func
[128]22; IDL> print, protype('init')
[69]23;      batch
[128]24; IDL> print, protype('plt')
[69]25;      proc
26;
[93]27; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
[69]28;                       Feb 2006
[118]29;
30; @version $Id$
[69]31;-
32;------------------------------------------------------------
33;------------------------------------------------------------
34;------------------------------------------------------------
35FUNCTION protype, file
36;
[114]37;
38  compile_opt idl2, strictarrsubs
39;
[69]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
[128]53 
[69]54  RETURN, -1
55END
Note: See TracBrowser for help on using the repository browser.