1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Display an IDL procedure header using widgets and the widget manager. |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Widget |
---|
8 | ; |
---|
9 | ; @param FILENAME {in}{required} {type=scalar string} |
---|
10 | ; the name of the file to display. |
---|
11 | ; FILENAME should be located in !path. |
---|
12 | ; ".pro" suffix will be appended if needed. |
---|
13 | ; |
---|
14 | ; @keyword _EXTRA |
---|
15 | ; Used to pass keywords to <proidl>XDISPLAYFILE</proidl> |
---|
16 | ; |
---|
17 | ; @restrictions |
---|
18 | ; Triggers the <proidl>XMANAGER</proidl> if it is not already in use. |
---|
19 | ; |
---|
20 | ; @examples |
---|
21 | ; IDL> xhelp,'plt' |
---|
22 | ; |
---|
23 | ; @history |
---|
24 | ; Written By Steve Richards, December 1990 |
---|
25 | ; Graceful error recovery, DMS, Feb, 1992. |
---|
26 | ; Modified to extract .pro documentation headers, PJR/ESRG mar94 |
---|
27 | ; Paul Ricchiazzi jun93 |
---|
28 | ; Institute for Computational Earth System Science |
---|
29 | ; University of California, Santa Barbara |
---|
30 | ; 7/1/99 : legeres mofification par Sebastien Masson : utilisation de |
---|
31 | ; <proidl>xdisplayfile</proidl>, de <pro>findfile</pro> et de _extra. |
---|
32 | ; 6/7/1999: compatibility mac and windows |
---|
33 | ; |
---|
34 | ; @version |
---|
35 | ; $Id$ |
---|
36 | ; |
---|
37 | ;- |
---|
38 | ; |
---|
39 | PRO xhelp, filename, _EXTRA=ex |
---|
40 | ; |
---|
41 | compile_opt idl2, strictarrsubs |
---|
42 | ; |
---|
43 | |
---|
44 | ; Are we sure filename is a string? |
---|
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)) |
---|
48 | return |
---|
49 | endif |
---|
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 ...') |
---|
85 | |
---|
86 | return |
---|
87 | end |
---|
88 | |
---|