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

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

bug fix and diagnostics improvements in xfile and xhelp. see 65. typo in some pro files

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