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

Last change on this file since 77 was 69, checked in by smasson, 18 years ago

debug + new xxx

File size: 1.7 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME: protype
6;
7; PURPOSE: test is a ".pro" file corresponds to an IDL procedure,
8;          function or batch file.
9;
10; CATEGORY:
11;
12; CALLING SEQUENCE: type = protype(profilename)
13;
14; INPUTS: A scalar of string type, the name of the ".pro" file to be tested
15;     if necessary, the input name is completed with '.pro'
16;     and its path found in !path
17;
18; KEYWORD PARAMETERS: NONE
19;
20; OUTPUTS: A scalar of string type: 'proc', 'func' or 'batch'
21;
22; COMMON BLOCKS: none
23;
24; SIDE EFFECTS:
25;
26; RESTRICTIONS:
27;
28; EXAMPLE:
29;
30;      IDL> print, protype('protype')
31;      func
32;      IDL> print, protype('protype.pro')
33;      func
34;      IDL> print, protype('init')
35;      batch
36;      IDL> print, protype('plt')
37;      proc
38;
39; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr)
40;                       Feb 2006
41;-
42;------------------------------------------------------------
43;------------------------------------------------------------
44;------------------------------------------------------------
45FUNCTION protype, file
46;
47  filepro = (find(file[0], /onlypro, /firstfound))[0]
48  if filepro EQ 'NOT FOUND' then return, -1
49  name = file_basename(filepro, '.pro')
50;
51  allines = getfile(filepro)
52  CASE 1 OF
53; this is a procedure
54    max(stregex(allines, '^ *pro ?' + name, /fold_case, /boolean)):RETURN, 'proc'
55; this is a function
56    max(stregex(allines, '^ *function ?' + name, /fold_case, /boolean)):RETURN, 'func'
57; this is an IDL batch file
58    ELSE:RETURN, 'batch'
59  ENDCASE
60 
61  RETURN, -1
62END
Note: See TracBrowser for help on using the repository browser.