1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Display an IDL procedure header using widgets and the widget manager. |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Utilities Widget |
---|
8 | ; |
---|
9 | ; @param FILENAME {in}{required} {type=scalar string} |
---|
10 | ; It is the name of the procedure or of the function |
---|
11 | ; we want to display (with or without .pro at the end). |
---|
12 | ; FILENAME should be located in !path. |
---|
13 | ; ".pro" suffix will be appended if needed. |
---|
14 | ; |
---|
15 | ; @keyword _EXTRA |
---|
16 | ; Used to pass keywords to <proidl>XDISPLAYFILE</proidl> |
---|
17 | ; |
---|
18 | ; @restrictions |
---|
19 | ; Triggers the <proidl>XMANAGER</proidl> if it is not already in use. |
---|
20 | ; |
---|
21 | ; @examples |
---|
22 | ; IDL> xhelp,'plt' |
---|
23 | ; |
---|
24 | ; @history |
---|
25 | ; Written By Steve Richards, December 1990 |
---|
26 | ; Graceful error recovery, DMS, Feb, 1992. |
---|
27 | ; Modified to extract .pro documentation headers, PJR/ESRG mar94 |
---|
28 | ; Paul Ricchiazzi jun93 |
---|
29 | ; Institute for Computational Earth System Science |
---|
30 | ; University of California, Santa Barbara |
---|
31 | ; 7/1/99 : legeres mofification par Sebastien Masson : utilisation de |
---|
32 | ; <proidl>xdisplayfile</proidl>, de <pro>findfile</pro> et de _extra. |
---|
33 | ; 6/7/1999: compatibility mac and windows |
---|
34 | ; |
---|
35 | ; @version |
---|
36 | ; $Id$ |
---|
37 | ; |
---|
38 | ;- |
---|
39 | ; |
---|
40 | PRO xhelp, filename, _EXTRA=ex |
---|
41 | ; |
---|
42 | compile_opt idl2, strictarrsubs |
---|
43 | ; |
---|
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 | ; |
---|
61 | ; Are we sure filename is a string? |
---|
62 | intype = size(filename, /type) |
---|
63 | if intype NE 7 then begin |
---|
64 | dummy = report(['Input parameter filename type : ' + size(filename,/TNAME) , $ |
---|
65 | 'Input parameter filename must be a string']) |
---|
66 | return |
---|
67 | endif |
---|
68 | ; |
---|
69 | ; find the file and display it! |
---|
70 | pfile = (find(filename, /first_found))[0] |
---|
71 | ; read it |
---|
72 | IF (pfile NE 'NOT FOUND') THEN BEGIN |
---|
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) |
---|
77 | IF ((cnt1 EQ 0) OR (cnt1 NE cnt2)) THEN BEGIN |
---|
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 |
---|
95 | ; remove the first useless lines |
---|
96 | IF n_elements(header) GT 1 THEN header = header[4:*] ELSE BEGIN |
---|
97 | dummy = report('file '+pfile+' has empty header... Use xfile') |
---|
98 | return |
---|
99 | ENDELSE |
---|
100 | ; |
---|
101 | xdisplayfile, 'dummy', text = header[1:*], title = pfile, _extra = ex |
---|
102 | ; |
---|
103 | endif else begin |
---|
104 | dummy = report(['Input parameter filename : ' + filename, $ |
---|
105 | filename + ' does not exist ...']) |
---|
106 | endelse |
---|
107 | ; |
---|
108 | return |
---|
109 | end |
---|