;+ ; ; @file_comments ; Display an IDL procedure header using widgets and the widget manager. ; ; @categories ; Widget ; ; @param FILENAME {in}{required} {type=scalar string} ; the name of the file to display. ; FILENAME should be located in !path. ; ".pro" suffix will be appended if needed. ; ; @keyword _EXTRA ; Used to pass keywords to XDISPLAYFILE ; ; @restrictions ; Triggers the XMANAGER if it is not already in use. ; ; @examples ; IDL> xhelp,'plt' ; ; @history ; Written By Steve Richards, December 1990 ; Graceful error recovery, DMS, Feb, 1992. ; Modified to extract .pro documentation headers, PJR/ESRG mar94 ; Paul Ricchiazzi jun93 ; Institute for Computational Earth System Science ; University of California, Santa Barbara ; 7/1/99 : legeres mofification par Sebastien Masson : utilisation de ; xdisplayfile, de findfile et de _extra. ; 6/7/1999: compatibility mac and windows ; ; @version ; $Id$ ; ;- ; PRO xhelp, filename, _EXTRA=ex ; compile_opt idl2, strictarrsubs ; ; Are we sure filename is a string? intype = size(filename, /type) if intype NE 7 then begin dummy = report('Input parameter must be a string and not a '+size(filename, /tname)) return endif ; find the file and display it! pfile = (find(filename, /first_found))[0] ; read it IF pfile NE 'NOT_FOUND' THEN BEGIN fulltext = getfile(pfile) ; find the ";+"and ";-" start = where(stregex(fulltext,'^ *;\+ *$', /boolean) EQ 1, cnt1) ending = where(stregex(fulltext,'^ *;- *$', /boolean) EQ 1, cnt2) IF cnt1 EQ 0 OR cnt1 NE cnt2 THEN BEGIN dummy = report('file '+pfile+' is badly written, no proper header found... Use xfile') return ENDIF ; do we have hidden parts? hide = where(stregex(fulltext, '^ *; *@hidden *$', /boolean) EQ 1) ; buid the text to display header = '' sepbloc = ['', string(replicate(byte('='), 60)), ''] FOR i = 0, cnt1-1 DO BEGIN ; is this part hidden ? st = start[i] ed = ending[i] IF st NE ed +1 THEN BEGIN ; non-empty bloc dummy = where(hide GT st AND hide LT ed, cnt) IF cnt EQ 0 THEN header = [header, '', sepbloc, fulltext[st+1:ed-1]] ENDIF ENDFOR ; remove the fisrt useless lines IF n_elements(header) GT 1 THEN header = header[4:*] ELSE BEGIN dummy = report('file '+pfile+' has empty header... Use xfile') return ENDELSE ; xdisplayfile, 'dummy', text = header[1:*], title = pfile, _extra = ex ; ENDIF ELSE dummy = report(filename + ' does not exist ...') return end