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

Last change on this file since 375 was 375, checked in by pinsard, 16 years ago

improvements of headers (paragraphs and alignments)

  • 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;
[325]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
[2]22;
[371]23;   IDL> xhelp,'plt'
24;
[223]25; @history
26; Written By Steve Richards, December 1990
[2]27;       Graceful error recovery, DMS, Feb, 1992.
28;       Modified to extract .pro documentation headers, PJR/ESRG mar94
[133]29;       Paul Ricchiazzi                            jun93
30;       Institute for Computational Earth System Science
31;       University of California, Santa Barbara
[375]32;  - 7/1/99 : legeres modification par Sebastien Masson : utilisation de
33;    <proidl>xdisplayfile</proidl>, de <pro>findfile</pro> et de _extra.
34;  - 6/7/1999: compatibility mac and windows
[133]35;
[223]36; @version
37; $Id$
[133]38;
[2]39;-
[232]40PRO xhelp, filename, _EXTRA=ex
[114]41;
42  compile_opt idl2, strictarrsubs
43;
[327]44  usage="xhelp, filename, _EXTRA=ex"
[266]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!
[285]70   pfile = find(filename, /firstfound)
[239]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.