source: trunk/SRC/Utilities/xhelp.pro @ 327

Last change on this file since 327 was 327, checked in by pinsard, 17 years ago

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1;+
2;
3; @file_comments
4; Display an IDL procedure header using widgets and the widget manager.
5;
6; @categories
7; Utilities Widget
8;
9; @param filename {in}{required} {type=scalar string}
10; It is the name of the procedure or of the function
11; we want to display (with or without .pro at the end).
12; FILENAME should be located in !path.
13; ".pro" suffix will be appended if needed.
14;
15; @keyword _EXTRA
16; Used to pass keywords to <proidl>XDISPLAYFILE</proidl>
17;
18; @restrictions
19; Triggers the <proidl>XMANAGER</proidl> if it is not already in use.
20;
21; @examples
22; IDL> xhelp,'plt'
23;
24; @history
25; Written By Steve Richards, December 1990
26;       Graceful error recovery, DMS, Feb, 1992.
27;       Modified to extract .pro documentation headers, PJR/ESRG mar94
28;       Paul Ricchiazzi                            jun93
29;       Institute for Computational Earth System Science
30;       University of California, Santa Barbara
31;  7/1/99 : legeres modification par Sebastien Masson : utilisation de
32;  <proidl>xdisplayfile</proidl>, de <pro>findfile</pro> et de _extra.
33;  6/7/1999: compatibility mac and windows
34;
35; @version
36; $Id$
37;
38;-
39PRO xhelp, filename, _EXTRA=ex
40;
41  compile_opt idl2, strictarrsubs
42;
43  usage="xhelp, filename, _EXTRA=ex"
44;
45; check parameters
46  check_param = N_PARAMS()
47  if (check_param EQ 0) then begin
48     dummy = report(['No input parameter', $
49                     'Usage : ' + usage])
50     return
51  endif
52;
53; check arguments
54  if arg_present(filename) then begin
55     dummy = report(['No input parameter filename', $
56                     'Usage : ' + usage])
57     return
58  endif
59;
60; Are we sure filename is a string?
61   intype = size(filename, /type)
62   if intype NE 7 then begin
63      dummy = report(['Input parameter filename type : ' + size(filename,/TNAME) , $
64                      'Input parameter filename must be a string'])
65      return
66   endif
67;
68; find the file and display it!
69   pfile = find(filename, /firstfound)
70; read it
71   IF (pfile NE 'NOT FOUND') THEN BEGIN
72     fulltext = getfile(pfile)
73; find the ";+"and ";-"
74     start = where(stregex(fulltext,'^ *;\+ *$', /boolean) EQ 1, cnt1)
75     ending = where(stregex(fulltext,'^ *;- *$', /boolean) EQ 1, cnt2)
76     IF ((cnt1 EQ 0) OR (cnt1 NE cnt2)) THEN BEGIN
77       dummy = report('file '+pfile+' is badly written, no proper header found... Use xfile')
78       return
79     ENDIF
80; do we have hidden parts?
81     hide = where(stregex(fulltext, '^ *; *@hidden *$', /boolean) EQ 1)
82; buid the text to display
83     header = ''
84     sepbloc = ['', string(replicate(byte('='), 60)), '']
85     FOR i = 0, cnt1-1 DO BEGIN
86; is this part hidden ?
87       st = start[i]
88       ed = ending[i]
89       IF st NE ed +1 THEN BEGIN ; non-empty bloc
90         dummy = where(hide GT st AND hide LT ed, cnt)
91       IF cnt EQ 0 THEN header = [header, '', sepbloc, fulltext[st+1:ed-1]]
92       ENDIF
93     ENDFOR
94; remove the first useless lines
95     IF n_elements(header) GT 1 THEN header = header[4:*] ELSE BEGIN
96       dummy = report('file '+pfile+' has empty header... Use xfile')
97       return
98     ENDELSE
99;
100     xdisplayfile, 'dummy', text = header[1:*], title = pfile, _extra = ex
101;
102   endif else begin
103     dummy = report(['Input parameter filename : ' + filename, $
104                     filename + ' does not exist ...'])
105   endelse
106;
107   return
108end
Note: See TracBrowser for help on using the repository browser.