[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 |
---|
| 7 | ; Widget |
---|
[2] | 8 | ; |
---|
[242] | 9 | ; @param FILENAME {in}{required} {type=scalar string} |
---|
| 10 | ; the name of the file to display. |
---|
| 11 | ; FILENAME should be located in !path. |
---|
[239] | 12 | ; ".pro" suffix will be appended if needed. |
---|
[2] | 13 | ; |
---|
[223] | 14 | ; @keyword _EXTRA |
---|
[260] | 15 | ; Used to pass keywords to <proidl>XDISPLAYFILE</proidl> |
---|
[2] | 16 | ; |
---|
[223] | 17 | ; @restrictions |
---|
[242] | 18 | ; Triggers the <proidl>XMANAGER</proidl> if it is not already in use. |
---|
[2] | 19 | ; |
---|
[223] | 20 | ; @examples |
---|
| 21 | ; IDL> xhelp,'plt' |
---|
[2] | 22 | ; |
---|
[223] | 23 | ; @history |
---|
| 24 | ; Written By Steve Richards, December 1990 |
---|
[2] | 25 | ; Graceful error recovery, DMS, Feb, 1992. |
---|
| 26 | ; Modified to extract .pro documentation headers, PJR/ESRG mar94 |
---|
[133] | 27 | ; Paul Ricchiazzi jun93 |
---|
| 28 | ; Institute for Computational Earth System Science |
---|
| 29 | ; University of California, Santa Barbara |
---|
[2] | 30 | ; 7/1/99 : legeres mofification par Sebastien Masson : utilisation de |
---|
[262] | 31 | ; <proidl>xdisplayfile</proidl>, de <pro>findfile</pro> et de _extra. |
---|
[136] | 32 | ; 6/7/1999: compatibility mac and windows |
---|
[133] | 33 | ; |
---|
[223] | 34 | ; @version |
---|
| 35 | ; $Id$ |
---|
[133] | 36 | ; |
---|
[2] | 37 | ;- |
---|
[231] | 38 | ; |
---|
[232] | 39 | PRO xhelp, filename, _EXTRA=ex |
---|
[114] | 40 | ; |
---|
| 41 | compile_opt idl2, strictarrsubs |
---|
| 42 | ; |
---|
[2] | 43 | |
---|
[133] | 44 | ; Are we sure filename is a string? |
---|
[239] | 45 | intype = size(filename, /type) |
---|
| 46 | if intype NE 7 then begin |
---|
| 47 | dummy = report('Input parameter must be a string and not a '+size(filename, /tname)) |
---|
[2] | 48 | return |
---|
| 49 | endif |
---|
[239] | 50 | ; find the file and display it! |
---|
| 51 | pfile = (find(filename, /first_found))[0] |
---|
| 52 | ; read it |
---|
| 53 | IF pfile NE 'NOT_FOUND' THEN BEGIN |
---|
| 54 | fulltext = getfile(pfile) |
---|
| 55 | ; find the ";+"and ";-" |
---|
| 56 | start = where(stregex(fulltext,'^ *;\+ *$', /boolean) EQ 1, cnt1) |
---|
| 57 | ending = where(stregex(fulltext,'^ *;- *$', /boolean) EQ 1, cnt2) |
---|
| 58 | IF cnt1 EQ 0 OR cnt1 NE cnt2 THEN BEGIN |
---|
| 59 | dummy = report('file '+pfile+' is badly written, no proper header found... Use xfile') |
---|
| 60 | return |
---|
| 61 | ENDIF |
---|
| 62 | ; do we have hidden parts? |
---|
| 63 | hide = where(stregex(fulltext, '^ *; *@hidden *$', /boolean) EQ 1) |
---|
| 64 | ; buid the text to display |
---|
| 65 | header = '' |
---|
| 66 | sepbloc = ['', string(replicate(byte('='), 60)), ''] |
---|
| 67 | FOR i = 0, cnt1-1 DO BEGIN |
---|
| 68 | ; is this part hidden ? |
---|
| 69 | st = start[i] |
---|
| 70 | ed = ending[i] |
---|
| 71 | IF st NE ed +1 THEN BEGIN ; non-empty bloc |
---|
| 72 | dummy = where(hide GT st AND hide LT ed, cnt) |
---|
| 73 | IF cnt EQ 0 THEN header = [header, '', sepbloc, fulltext[st+1:ed-1]] |
---|
| 74 | ENDIF |
---|
| 75 | ENDFOR |
---|
| 76 | ; remove the fisrt useless lines |
---|
| 77 | IF n_elements(header) GT 1 THEN header = header[4:*] ELSE BEGIN |
---|
| 78 | dummy = report('file '+pfile+' has empty header... Use xfile') |
---|
| 79 | return |
---|
| 80 | ENDELSE |
---|
| 81 | ; |
---|
| 82 | xdisplayfile, 'dummy', text = header[1:*], title = pfile, _extra = ex |
---|
| 83 | ; |
---|
| 84 | ENDIF ELSE dummy = report(filename + ' does not exist ...') |
---|
[2] | 85 | |
---|
| 86 | return |
---|
| 87 | end |
---|
| 88 | |
---|